@meteor-it/logger
Advanced tools
Comparing version 2.2.6 to 2.2.7
82
index.js
"use strict"; | ||
require("./colors"); | ||
let cluster = null; | ||
if (process.env.__NODE__ !== 'undefined') { | ||
cluster = require('cluster'); | ||
} | ||
else { | ||
cluster = { | ||
isMaster: true, | ||
isWorker: false, | ||
on() { }, | ||
emit() { } | ||
}; | ||
} | ||
const DEBUG = process.env.DEBUG || ''; | ||
@@ -192,38 +180,31 @@ var LOGGER_ACTIONS; | ||
static _write(what) { | ||
if (cluster.isWorker) { | ||
process.send({ | ||
loggerAction: what | ||
}); | ||
} | ||
else { | ||
if (Logger.receivers.length === 0) { | ||
if (!Logger.noReceiversWarned) { | ||
console._log('No receivers are defined for logger! See docs for info about this!'); | ||
Logger.noReceiversWarned = true; | ||
} | ||
switch (what.type) { | ||
case LOGGER_ACTIONS.DEBUG: | ||
case LOGGER_ACTIONS.LOG: | ||
console._log(what.line, ...what.params); | ||
break; | ||
case LOGGER_ACTIONS.ERROR: | ||
console._error(what.line, ...what.params); | ||
break; | ||
case LOGGER_ACTIONS.WARNING: | ||
console._warn(what.line, ...what.params); | ||
break; | ||
default: | ||
console._log(what); | ||
} | ||
return; | ||
if (Logger.receivers.length === 0) { | ||
if (!Logger.noReceiversWarned) { | ||
console._log('No receivers are defined for logger! See docs for info about this!'); | ||
Logger.noReceiversWarned = true; | ||
} | ||
if (Logger.isRepeating(what.name, what.line, what.type)) | ||
Logger.repeatCount++; | ||
else | ||
Logger.resetRepeating(what.name, what.line, what.type); | ||
if (REPEATABLE_ACTIONS.indexOf(what.type) === -1) | ||
what.repeats = Logger.repeatCount; | ||
what.repeated = what.repeats && what.repeats > 0; | ||
Logger.receivers.forEach(receiver => receiver.write(what)); | ||
switch (what.type) { | ||
case LOGGER_ACTIONS.DEBUG: | ||
case LOGGER_ACTIONS.LOG: | ||
console._log(what.line, ...what.params); | ||
break; | ||
case LOGGER_ACTIONS.ERROR: | ||
console._error(what.line, ...what.params); | ||
break; | ||
case LOGGER_ACTIONS.WARNING: | ||
console._warn(what.line, ...what.params); | ||
break; | ||
default: | ||
console._log(what); | ||
} | ||
return; | ||
} | ||
if (Logger.isRepeating(what.name, what.line, what.type)) | ||
Logger.repeatCount++; | ||
else | ||
Logger.resetRepeating(what.name, what.line, what.type); | ||
if (REPEATABLE_ACTIONS.indexOf(what.type) === -1) | ||
what.repeats = Logger.repeatCount; | ||
what.repeated = what.repeats && what.repeats > 0; | ||
Logger.receivers.forEach(receiver => receiver.write(what)); | ||
} | ||
@@ -260,6 +241,9 @@ static resetRepeating(provider, message, type) { | ||
loggerLogger = new Logger('logger'); | ||
for (let method of ['log', 'error', 'warn', 'err', 'warning']) { | ||
console['_' + method] = console[method]; | ||
console[method] = (...args) => consoleLogger[method](...args); | ||
if (!console._patchedByLogger) { | ||
for (let method of ['log', 'error', 'warn', 'err', 'warning']) { | ||
console['_' + method] = console[method]; | ||
console[method] = (...args) => consoleLogger[method](...args); | ||
} | ||
console._patchedByLogger = true; | ||
} | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
{"name":"@meteor-it/logger","version":"2.2.6","description":"Most powerfull logger for node.js","main":"index.js","keywords":["meteor-it","logger"],"author":"Yaroslaw Bolyukin <iam@f6cf.pw> (http://f6cf.pw/)","license":"MIT","dependencies":{"@meteor-it/platform":"latest","@meteor-it/reflection":"latest","@meteor-it/terminal":"latest","@meteor-it/utils":"latest"}} | ||
{"name":"@meteor-it/logger","version":"2.2.7","description":"Most powerfull logger for node.js","main":"index.js","keywords":["meteor-it","logger"],"author":"Yaroslaw Bolyukin <iam@f6cf.pw> (http://f6cf.pw/)","license":"MIT","dependencies":{"@meteor-it/platform":"latest","@meteor-it/reflection":"latest","@meteor-it/terminal":"latest","@meteor-it/utils":"latest"}} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
3
41846
626