Add logger
This commit is contained in:
parent
8042d412f1
commit
61467f2f8a
|
@ -0,0 +1,27 @@
|
|||
import winston from 'winston';
|
||||
|
||||
const { format } = winston;
|
||||
|
||||
|
||||
const customFormat = format.printf(({
|
||||
level,
|
||||
message,
|
||||
label,
|
||||
timestamp,
|
||||
}) => `${timestamp} [${label}] ${level}: ${message}`);
|
||||
|
||||
const logger = winston.createLogger({
|
||||
level: 'info',
|
||||
format: format.combine(
|
||||
format.label({ label: 'umbrello-bot' }),
|
||||
format.timestamp(),
|
||||
customFormat,
|
||||
),
|
||||
defaultMeta: { service: 'user-service' },
|
||||
transports: [
|
||||
new winston.transports.File({ filename: 'error.log', level: 'error' }),
|
||||
new winston.transports.File({ filename: 'combined.log' }),
|
||||
],
|
||||
});
|
||||
|
||||
export default logger;
|
Loading…
Reference in New Issue