24 lines
896 B
JavaScript
24 lines
896 B
JavaScript
const winston = require("winston");
|
|
const app_conf = require("../config/app.conf");
|
|
const path = require("path");
|
|
|
|
/*
|
|
* Initialize console and file logger
|
|
*/
|
|
const logger = winston.createLogger({
|
|
levels: winston.config.syslog.levels,
|
|
level: process.env.LOG_LEVEL || app_conf.logger.level,
|
|
format: winston.format.combine(
|
|
winston.format.timestamp({
|
|
format: app_conf.timestamp_format,
|
|
}),
|
|
winston.format.printf((info) => `[${info.timestamp}][${info.level}]: ${info.message}`)
|
|
),
|
|
transports: [
|
|
new winston.transports.File({ filename: path.join(path.dirname(require.main.filename), app_conf.logger.error_path), level: "error", }),
|
|
new winston.transports.File({ filename: path.join(path.dirname(require.main.filename), app_conf.logger.full_path) }),
|
|
new winston.transports.Console()
|
|
],
|
|
});
|
|
|
|
module.exports = logger; |