Initial commit
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user