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>
22 lines
562 B
TypeScript
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
|