FRE-5006: VoicePrint quality improvements
- P2-1: Consolidate mock ML logic to Python canonical source - P2-2: Fix weak hashes with SHA-256 - P2-3: Parallelize batch processing with Promise.allSettled() - P2-4: Add DI pattern support to services - P2-5: Add structured logging utility - P3-2: Persist batch jobId for result retrieval Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
36
services/voiceprint/src/logger.ts
Normal file
36
services/voiceprint/src/logger.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { FastifyLoggerOptions } from 'fastify';
|
||||
|
||||
export interface Logger {
|
||||
info(message: string, context?: Record<string, unknown>): void;
|
||||
warn(message: string, context?: Record<string, unknown>): void;
|
||||
error(message: string, context?: Record<string, unknown>): void;
|
||||
debug(message: string, context?: Record<string, unknown>): void;
|
||||
}
|
||||
|
||||
export class ConsoleLogger implements Logger {
|
||||
info(message: string, context?: Record<string, unknown>): void {
|
||||
const timestamp = new Date().toISOString();
|
||||
const logContext = context ? ` ${JSON.stringify(context)}` : '';
|
||||
console.log(`[${timestamp}] [INFO] ${message}${logContext}`);
|
||||
}
|
||||
|
||||
warn(message: string, context?: Record<string, unknown>): void {
|
||||
const timestamp = new Date().toISOString();
|
||||
const logContext = context ? ` ${JSON.stringify(context)}` : '';
|
||||
console.warn(`[${timestamp}] [WARN] ${message}${logContext}`);
|
||||
}
|
||||
|
||||
error(message: string, context?: Record<string, unknown>): void {
|
||||
const timestamp = new Date().toISOString();
|
||||
const logContext = context ? ` ${JSON.stringify(context)}` : '';
|
||||
console.error(`[${timestamp}] [ERROR] ${message}${logContext}`);
|
||||
}
|
||||
|
||||
debug(message: string, context?: Record<string, unknown>): void {
|
||||
const timestamp = new Date().toISOString();
|
||||
const logContext = context ? ` ${JSON.stringify(context)}` : '';
|
||||
console.debug(`[${timestamp}] [DEBUG] ${message}${logContext}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const logger = new ConsoleLogger();
|
||||
Reference in New Issue
Block a user