Skip to content

Commit

Permalink
feat: adding detail log in each handler
Browse files Browse the repository at this point in the history
  • Loading branch information
NarwhalChen committed Jan 12, 2025
1 parent f20ec64 commit 1f86f37
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,10 @@ export class BackendFileReviewHandler implements BuildHandler<string> {
model: 'gpt-4o-mini',
messages: [{ content: modificationPrompt, role: 'system' }],
});

// Extract new content and write back
const newContent = formatResponse(response);
await fs.writeFile(filePath, newContent, 'utf-8');

this.logger.debug('modification code generated and parsed successfully.');
this.logger.log(`Successfully modified ${fileName}`);
} catch (error) {
this.logger.error(`Error modifying file ${fileName}:`, error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export class BackendRequirementHandler
model: 'gpt-4o-mini',
messages: [{ content: overviewPrompt, role: 'system' }],
});
this.logger.debug('Overview code generated and parsed successfully.');
} catch (error) {
this.logger.error('Error generating backend overview:', error);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class DatabaseRequirementHandler implements BuildHandler<string> {
model: 'gpt-4o-mini',
messages: [{ content: prompt, role: 'system' }],
});
this.logger.debug('Database code generated and parsed successfully.');
return {
success: true,
data: removeCodeBlockFences(dbRequirementsContent),
Expand Down
3 changes: 3 additions & 0 deletions backend/src/build-system/handlers/database/schemas/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class DBSchemaHandler implements BuildHandler {
model: 'gpt-4o-mini',
messages: [{ content: analysisPrompt, role: 'system' }],
});
this.logger.debug('Analysis code generated and parsed successfully.');
dbAnalysis = analysisResponse;
} catch (error) {
this.logger.error('Error during database requirements analysis:', error);
Expand Down Expand Up @@ -107,6 +108,7 @@ export class DBSchemaHandler implements BuildHandler {
model: 'gpt-4o-mini',
messages: [{ content: schemaPrompt, role: 'system' }],
});
this.logger.debug('Schema code generated and parsed successfully.');
schemaContent = formatResponse(schemaResponse);
} catch (error) {
this.logger.error('Error during schema generation:', error);
Expand All @@ -130,6 +132,7 @@ export class DBSchemaHandler implements BuildHandler {
model: 'gpt-4o-mini',
messages: [{ content: validationPrompt, role: 'system' }],
});
this.logger.debug('Validation code generated and parsed successfully.');
validationResponse = formatResponse(validationResult);
} catch (error) {
this.logger.error('Error during schema validation:', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export class FileArchGenerateHandler implements BuildHandler<string> {
model: 'gpt-4o-mini',
messages: [{ content: prompt, role: 'system' }],
});
this.logger.debug('File arch code generated and parsed successfully.');

const tagContent = parseGenerateTag(fileArchContent);
jsonData = extractJsonFromText(tagContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ export class FileStructureHandler implements BuildHandler<FileStructOutput> {
model: 'gpt-4o-mini',
messages: [{ content: prompt, role: 'system' }],
});
this.logger.debug('File structure generated and parsed successfully.');
} catch (error) {
this.logger.error('Error during file structure generation:', error);
return {
Expand Down Expand Up @@ -126,6 +127,7 @@ export class FileStructureHandler implements BuildHandler<FileStructOutput> {
model: 'gpt-4o-mini',
messages: [{ content: convertToJsonPrompt, role: 'system' }],
});
this.logger.debug('File structure generated and parsed successfully.');
} catch (error) {
this.logger.error('Error during tree to JSON conversion:', error);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export class PRDHandler implements BuildHandler {
model: 'gpt-4o-mini',
messages: [{ content: prompt, role: 'system' }],
});
this.logger.debug('Product code generated and parsed successfully.');
this.logger.log('Received full PRD content from LLM server.');
return prdContent;
}
Expand Down
2 changes: 2 additions & 0 deletions backend/src/build-system/handlers/ux/datamap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { removeCodeBlockFences } from 'src/build-system/utils/strings';
* Handler for generating the UX Data Map document.
*/
export class UXDatamapHandler implements BuildHandler<string> {
private logger = new Logger(UXDatamapHandler.name);
readonly id = 'op:UX:DATAMAP:DOC';

async run(context: BuilderContext): Promise<BuildResult<string>> {
Expand All @@ -27,6 +28,7 @@ export class UXDatamapHandler implements BuildHandler<string> {
model: 'gpt-4o-mini',
messages: [{ content: prompt, role: 'system' }],
});
this.logger.debug('UX Data Map generated and parsed successfully.');
Logger.log('UX Data Map Content: ', uxDatamapContent);

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class UXSMDHandler implements BuildHandler<string> {
model,
messages: [{ content: prompt, role: 'system' }],
});


this.logger.log('Received full UXSMD content from LLM server.');
return uxsmdContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class UXSitemapStructureHandler implements BuildHandler<string> {
model: 'gpt-4o-mini',
messages: [{ content: prompt, role: 'system' }],
});
this.logger.debug('Ux structure generated and parsed successfully.');

return {
success: true,
Expand Down

0 comments on commit 1f86f37

Please sign in to comment.