Files
superlist/apps/api/src/lib/logger.ts
Jose Selesan 5a8604298e fix(api): fall back to defaults when LOG_LEVEL or MAIL_FROM are empty
Compose defines unset optional variables as empty strings, so `??` kept
"" and Pino crashed on startup with an empty level, leaving the api
container unhealthy on Dokploy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 09:41:53 -03:00

22 lines
562 B
TypeScript

import { pino } from 'pino'
const isProduction = process.env.NODE_ENV === 'production'
/**
* Single logger instance for the whole API. Import it wherever you need to log —
* never use `console.log` in the backend.
*/
export const logger = pino({
level: process.env.LOG_LEVEL || (isProduction ? 'info' : 'debug'),
...(isProduction
? {}
: {
transport: {
target: 'pino-pretty',
options: { colorize: true, translateTime: 'HH:MM:ss', ignore: 'pid,hostname' },
},
}),
})
export type Logger = typeof logger