mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 01:26:29 -04:00
fix logger.js, move jsdom in startApplication
This commit is contained in:
parent
0ef6f89d44
commit
a1c7f20990
4 changed files with 27 additions and 16 deletions
15
js/logger.js
15
js/logger.js
|
@ -24,7 +24,16 @@
|
|||
}
|
||||
})(this, function (config) {
|
||||
let logLevel;
|
||||
if ((typeof exports === "object" && process.env.JEST_WORKER_ID === undefined) || typeof exports !== "object") {
|
||||
let enableLog;
|
||||
if (typeof exports === "object") {
|
||||
// in nodejs and not running with jest
|
||||
enableLog = (process.env.JEST_WORKER_ID === undefined);
|
||||
} else {
|
||||
// in browser and not running with jsdom
|
||||
enableLog = (typeof window === 'object' && window.name === 'nodejs');
|
||||
};
|
||||
|
||||
if (enableLog) {
|
||||
logLevel = {
|
||||
debug: Function.prototype.bind.call(console.debug, console),
|
||||
log: Function.prototype.bind.call(console.log, console),
|
||||
|
@ -35,8 +44,8 @@
|
|||
groupCollapsed: Function.prototype.bind.call(console.groupCollapsed, console),
|
||||
groupEnd: Function.prototype.bind.call(console.groupEnd, console),
|
||||
time: Function.prototype.bind.call(console.time, console),
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console)
|
||||
// timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||
timeEnd: Function.prototype.bind.call(console.timeEnd, console),
|
||||
timeStamp: Function.prototype.bind.call(console.timeStamp, console)
|
||||
};
|
||||
|
||||
logLevel.setLogLevel = function (newLevel) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue