16 lines
392 B
TypeScript
16 lines
392 B
TypeScript
import pino from 'pino';
|
|
|
|
export const logger = pino({
|
|
level: process.env.LOG_LEVEL || 'info',
|
|
transport: { target: 'pino-pretty', options: { colorize: true } },
|
|
});
|
|
|
|
process.on('uncaughtException', (err) => {
|
|
logger.fatal({ err }, 'Uncaught exception');
|
|
process.exit(1);
|
|
});
|
|
|
|
process.on('unhandledRejection', (reason) => {
|
|
logger.error({ err: reason }, 'Unhandled rejection');
|
|
});
|