mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 02:58:08 +08:00
32 lines
928 B
JavaScript
32 lines
928 B
JavaScript
const winston = require('winston');
|
|
const config = require('@/config');
|
|
|
|
const logger = winston.createLogger({
|
|
level: config.loggerLevel,
|
|
format: winston.format.json(),
|
|
transports: [
|
|
//
|
|
// - Write to all logs with level `info` and below to `combined.log`
|
|
// - Write all logs error (and below) to `error.log`.
|
|
//
|
|
new winston.transports.File({
|
|
filename: 'logs/error.log',
|
|
level: 'error',
|
|
}),
|
|
new winston.transports.File({ filename: 'logs/combined.log' }),
|
|
],
|
|
});
|
|
|
|
//
|
|
// If we're not in production then log to the `console` with the format:
|
|
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
|
|
//
|
|
logger.add(
|
|
new winston.transports.Console({
|
|
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
|
|
silent: process.env.NODE_ENV === 'test',
|
|
})
|
|
);
|
|
|
|
module.exports = logger;
|