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.
30 lines
804 B
30 lines
804 B
let winston = require('winston');
|
|
|
|
let logger = winston.createLogger({
|
|
level: 'info',
|
|
format: winston.format.combine(
|
|
winston.format.timestamp(),
|
|
winston.format.splat(),
|
|
winston.format.json()
|
|
),
|
|
defaultMeta: { service: 'baphomet-js' },
|
|
transports: [
|
|
new winston.transports.File({ filename: 'log/error.log', level: 'error' }),
|
|
new winston.transports.File({ filename: 'log/combined.log' })
|
|
]
|
|
});
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
logger.add(new winston.transports.Console({
|
|
format: winston.format.combine(
|
|
winston.format.simple()
|
|
)
|
|
}));
|
|
}
|
|
|
|
if ('LOG_LEVE' in process.env) {
|
|
logger.info('LOG_LEVEL:', process.env.LOG_LEVEL)
|
|
logger.level = process.env.LOG_LEVEL
|
|
}
|
|
|
|
exports.logger = logger;
|