fix logger.js, move jsdom in startApplication

This commit is contained in:
Karsten Hassel 2021-09-24 21:30:51 +02:00
parent 0ef6f89d44
commit a1c7f20990
4 changed files with 27 additions and 16 deletions

View file

@ -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) {