Changeset View
Changeset View
Standalone View
Standalone View
lib/app/logger.js
"use strict"; | |||||
const locreq = require("locreq")(__dirname); | const locreq = require("locreq")(__dirname); | ||||
const winston = require("winston"); | const winston = require("winston"); | ||||
const { getTimeDifference } = locreq("lib/utils/get-datetime.js"); | const { getTimeDifference } = locreq("lib/utils/get-datetime.js"); | ||||
/* | /* | ||||
This is the custom logger level and color configuration. | This is the custom logger level and color configuration. | ||||
@levels - default logger levels, 0 being the lowest importance, 4 being the highest: | @levels - default logger levels, 0 being the lowest importance, 4 being the highest: | ||||
Show All 39 Lines | const Logger = function(app) { | ||||
} | } | ||||
const logger = new winston.Logger({ | const logger = new winston.Logger({ | ||||
levels: Logger.custom.levels, | levels: Logger.custom.levels, | ||||
colors: Logger.custom.colors, | colors: Logger.custom.colors, | ||||
transports: transports_array, | transports: transports_array, | ||||
}); | }); | ||||
logger.rewriters.push(function(level, msg, meta) { | logger.rewriters.push((level, msg, meta) => { | ||||
let ret = ""; | let ret = ""; | ||||
if (Object.keys(meta).length) { | if (Object.keys(meta).length) { | ||||
let message = "\n"; | let message = "\n"; | ||||
for (const prop in meta) { | for (const prop in meta) { | ||||
message += ` - ${prop}: ${JSON.stringify(meta[prop])}\n`; | message += ` - ${prop}: ${JSON.stringify(meta[prop])}\n`; | ||||
} | } | ||||
ret = message; | ret = message; | ||||
} | } | ||||
Show All 29 Lines |