feat: enhance logging and linting functionality with detailed reports
All checks were successful
Lint / lint (pull_request) Successful in 16s

This commit is contained in:
2026-03-26 13:03:10 +01:00
parent b54a94c6d3
commit 79ea7dfc7e
8 changed files with 133 additions and 44 deletions

View File

@@ -1,3 +1,5 @@
import fs from 'fs-extra';
const colors = {
reset: '\x1b[0m',
bright: '\x1b[1m',
@@ -10,6 +12,21 @@ const colors = {
type Color = keyof typeof colors;
let _logFilePath: string | null = null;
/** Initialises the generation log file, overwriting any previous run. */
export function initGenerationLog(filePath: string): void {
_logFilePath = filePath;
fs.writeFileSync(filePath, `Generation log — ${new Date().toISOString()}\n${'='.repeat(60)}\n`);
}
/** Writes a detailed entry to the generation log file (not to console). */
export function logDetail(category: string, message: string): void {
if (!_logFilePath) return;
const line = `[${new Date().toISOString()}] [${category.toUpperCase().padEnd(8)}] ${message}\n`;
fs.appendFileSync(_logFilePath, line);
}
/** Prints a console message with the given ANSI colour. */
export function log(message: string, color: Color = 'reset'): void {
console.log(`${colors[color]}${message}${colors.reset}`);