mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
again logger.js due to problem with e2e test
This commit is contained in:
parent
eb63745664
commit
53c789bff9
53
js/logger.js
53
js/logger.js
@ -9,13 +9,11 @@
|
|||||||
*/
|
*/
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof exports === "object") {
|
if (typeof exports === "object") {
|
||||||
if (process.env.JEST_WORKER_ID === undefined) {
|
// add timestamps in front of log messages
|
||||||
// add timestamps in front of log messages
|
require("console-stamp")(console, {
|
||||||
require("console-stamp")(console, {
|
pattern: "yyyy-mm-dd HH:MM:ss.l",
|
||||||
pattern: "yyyy-mm-dd HH:MM:ss.l",
|
include: ["debug", "log", "info", "warn", "error"]
|
||||||
include: ["debug", "log", "info", "warn", "error"]
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Node, CommonJS-like
|
// Node, CommonJS-like
|
||||||
module.exports = factory(root.config);
|
module.exports = factory(root.config);
|
||||||
@ -39,31 +37,30 @@
|
|||||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
||||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||||
};
|
};
|
||||||
|
|
||||||
logLevel.setLogLevel = function (newLevel) {
|
|
||||||
if (newLevel) {
|
|
||||||
Object.keys(logLevel).forEach(function (key, index) {
|
|
||||||
if (!newLevel.includes(key.toLocaleUpperCase())) {
|
|
||||||
logLevel[key] = function () {};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
logLevel = {
|
logLevel = {
|
||||||
debug: function () {},
|
debug: Function.prototype.bind.call(console.debug, console),
|
||||||
log: function () {},
|
log: Function.prototype.bind.call(console.log, console),
|
||||||
info: function () {},
|
info: Function.prototype.bind.call(console.info, console),
|
||||||
warn: function () {},
|
warn: Function.prototype.bind.call(console.warn, console),
|
||||||
error: function () {},
|
error: Function.prototype.bind.call(console.error, console),
|
||||||
group: function () {},
|
group: Function.prototype.bind.call(console.group, console),
|
||||||
groupCollapsed: function () {},
|
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
|
||||||
groupEnd: function () {},
|
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
|
||||||
time: function () {},
|
time: Function.prototype.bind.call(console.time, console),
|
||||||
timeEnd: function () {},
|
timeEnd: Function.prototype.bind.call(console.timeEnd, console)
|
||||||
timeStamp: function () {}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logLevel.setLogLevel = function (newLevel) {
|
||||||
|
if (newLevel) {
|
||||||
|
Object.keys(logLevel).forEach(function (key, index) {
|
||||||
|
if (!newLevel.includes(key.toLocaleUpperCase())) {
|
||||||
|
logLevel[key] = function () {};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return logLevel;
|
return logLevel;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user