chore: scaffold turbo monorepo with hono api and react admin web
This commit is contained in:
21
apps/api/src/lib/logger.ts
Normal file
21
apps/api/src/lib/logger.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
Reference in New Issue
Block a user