SIU_Dran_net/Server/utils/logger.js

28 lines
631 B
JavaScript

import { createLogger, format, transports } from 'winston';
import caller from 'caller';
const myFormat = format.printf(info => {
const file = caller();
return `[${info.timestamp}] [${info.level}] ${info.message}`;
});
const logger = createLogger({
format: format.combine(
format.colorize(),
format.timestamp(),
myFormat
),
transports: [
new transports.File({
maxsize: 5120000,
maxFiles: 5,
filename: `./logs/log-api.log`
}),
new transports.Console({
level: 'debug'
})
]
});
export default logger;