/** * Script to validate the logging system implementation * Run with: npx ts-node scripts/validate-logging.ts */ import * as fs from 'fs'; import * as path from 'path'; interface ValidationResult { name: string; passed: boolean; message: string; } const results: ValidationResult[] = []; function validate(name: string, condition: boolean, message: string): void { results.push({ name, passed: condition, message }); } function fileExists(filePath: string): boolean { return fs.existsSync(path.join(process.cwd(), filePath)); } function fileContains(filePath: string, searchString: string): boolean { if (!fileExists(filePath)) return false; const content = fs.readFileSync(path.join(process.cwd(), filePath), 'utf-8'); return content.includes(searchString); } console.log('šŸ” Validating Logging System Implementation...\n'); // Check core files exist validate( 'Core Files', fileExists('src/core/logging/log.model.ts') && fileExists('src/core/logging/log.service.ts') && fileExists('src/core/logging/log.sender.ts') && fileExists('src/core/logging/log.router-listener.ts') && fileExists('src/core/logging/log.visibility-listener.ts') && fileExists('src/core/logging/environment.ts') && fileExists('src/core/logging/index.ts'), 'All core logging files exist' ); // Check instrumentation validate( 'AppComponent Instrumentation', fileContains('src/app.component.ts', 'LogService') && fileContains('src/app.component.ts', 'APP_START') && fileContains('src/app.component.ts', 'APP_STOP') && fileContains('src/app.component.ts', 'SEARCH_EXECUTED') && fileContains('src/app.component.ts', 'BOOKMARKS_MODIFY') && fileContains('src/app.component.ts', 'CALENDAR_SEARCH_EXECUTED'), 'AppComponent is instrumented with logging' ); validate( 'ThemeService Instrumentation', fileContains('src/app/core/services/theme.service.ts', 'LogService') && fileContains('src/app/core/services/theme.service.ts', 'THEME_CHANGE'), 'ThemeService is instrumented with logging' ); validate( 'GraphSettingsService Instrumentation', fileContains('src/app/graph/graph-settings.service.ts', 'LogService') && fileContains('src/app/graph/graph-settings.service.ts', 'GRAPH_VIEW_SETTINGS_CHANGE'), 'GraphSettingsService is instrumented with logging' ); // Check providers validate( 'Providers Integration', fileContains('index.tsx', 'initializeRouterLogging') && fileContains('index.tsx', 'initializeVisibilityLogging') && fileContains('index.tsx', 'APP_INITIALIZER'), 'Logging providers are integrated in index.tsx' ); // Check documentation validate( 'Documentation', fileExists('docs/README-logging.md') && fileExists('docs/LOGGING_QUICK_START.md') && fileExists('LOGGING_IMPLEMENTATION.md') && fileExists('LOGGING_SUMMARY.md'), 'All documentation files exist' ); // Check tests validate( 'Tests', fileExists('src/core/logging/log.service.spec.ts') && fileExists('src/core/logging/log.sender.spec.ts') && fileExists('e2e/logging.spec.ts'), 'All test files exist' ); // Check example backend validate( 'Example Backend', fileExists('server/log-endpoint-example.mjs'), 'Example backend endpoint exists' ); // Print results console.log('šŸ“Š Validation Results:\n'); let allPassed = true; results.forEach(result => { const icon = result.passed ? 'āœ…' : 'āŒ'; console.log(`${icon} ${result.name}`); console.log(` ${result.message}\n`); if (!result.passed) allPassed = false; }); console.log('─────────────────────────────────────────────────────'); if (allPassed) { console.log('āœ… All validations passed! Logging system is complete.'); console.log('\nšŸ“š Next steps:'); console.log(' 1. Run: npm run dev'); console.log(' 2. Open DevTools → Network → Filter /api/log'); console.log(' 3. Perform actions and observe logs'); console.log('\nšŸ“– Documentation: docs/README-logging.md'); process.exit(0); } else { console.log('āŒ Some validations failed. Please check the implementation.'); process.exit(1); }