blob: 4ce015084d16c80a6c30ebe1a65d18285618671e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import winston from 'winston';
const enumerateErrorFormat = winston.format((info) => {
if (info instanceof Error) {
Object.assign(info, { message: info.stack });
}
return info;
});
export const logger = winston.createLogger({
level: process.env.LOGGING_LEVEL === 'development' ? 'debug' : 'info',
format: winston.format.combine(
enumerateErrorFormat(),
winston.format.colorize(),
winston.format.splat(),
winston.format.printf(({ level, message }) => `${level}: ${message}`)
),
transports: [
new winston.transports.Console({
stderrLevels: ['error'],
}),
],
});
|