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();
