import { pino } from 'pino';
import { useConfig } from '@kevisual/use-config/env';

const config = useConfig();

export const logger = pino({
  level: config.LOG_LEVEL || 'info',
  transport: {
    target: 'pino-pretty',
    options: {
      colorize: true,
      translateTime: 'SYS:standard',
      ignore: 'pid,hostname',
    },
  },
  serializers: {
    error: pino.stdSerializers.err,
    req: pino.stdSerializers.req,
    res: pino.stdSerializers.res,
  },
  // base: {
  //   app: 'ai-videos',
  //   env: process.env.NODE_ENV || 'development',
  // },
});

export const logError = (message: string, data?: any) => logger.error({ data }, message);
export const logWarning = (message: string, data?: any) => logger.warn({ data }, message);
export const logInfo = (message: string, data?: any) => logger.info({ data }, message);
export const logDebug = (message: string, data?: any) => logger.debug({ data }, message);

export const log = {
  error: logError,
  warn: logWarning,
  info: logInfo,
  debug: logDebug,
};
