You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
overseerr/server/logger.ts

33 lines
789 B

import * as winston from 'winston';
import path from 'path';
const hformat = winston.format.printf(
({ level, label, message, timestamp, ...metadata }) => {
let msg = `${timestamp} [${level}]${
label ? `[${label}]` : ''
}: ${message} `;
if (Object.keys(metadata).length > 0) {
msg += JSON.stringify(metadata);
}
return msg;
}
);
const logger = winston.createLogger({
level: process.env.LOG_LEVEL || 'debug',
format: winston.format.combine(
winston.format.colorize(),
winston.format.splat(),
winston.format.timestamp(),
hformat
),
transports: [
new winston.transports.Console(),
new winston.transports.File({
filename: path.join(__dirname, '../config/logs/overseerr.log'),
}),
],
});
export default logger;