import pino from "pino";

const isProduction = process.env["NODE_ENV"] === "production";

const LOG_LEVEL = process.env["LOG_LEVEL"] ?? "info";
const devDestination = pino.destination({ dest: 1, sync: true });

export const logger = isProduction
  ? pino({
      level: LOG_LEVEL,
      base: { service: "capakraken-api" },
    })
  : pino(
      {
        level: LOG_LEVEL,
        base: { service: "capakraken-api" },
        formatters: {
          level(label: string) {
            return { level: label };
          },
        },
      },
      devDestination,
    );

export type Logger = typeof logger;
