mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Make logger configurable
This commit is contained in:
parent
f2d03a511e
commit
d0c6a4ee6d
@ -28,6 +28,7 @@ var config = {
|
|||||||
httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true
|
httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true
|
||||||
|
|
||||||
language: "en",
|
language: "en",
|
||||||
|
logLevel: ["INFO", "LOG", "WARN", "ERROR"],
|
||||||
timeFormat: 24,
|
timeFormat: 24,
|
||||||
units: "metric",
|
units: "metric",
|
||||||
// serverOnly: true/false/"local" ,
|
// serverOnly: true/false/"local" ,
|
||||||
|
15
js/logger.js
15
js/logger.js
@ -18,7 +18,8 @@
|
|||||||
root.Log = factory(root.config);
|
root.Log = factory(root.config);
|
||||||
}
|
}
|
||||||
}(this, function (config) {
|
}(this, function (config) {
|
||||||
return {
|
|
||||||
|
let logLevel = {
|
||||||
info: Function.prototype.bind.call(console.info, console),
|
info: Function.prototype.bind.call(console.info, console),
|
||||||
log: Function.prototype.bind.call(console.log, console),
|
log: Function.prototype.bind.call(console.log, console),
|
||||||
error: Function.prototype.bind.call(console.error, console),
|
error: Function.prototype.bind.call(console.error, console),
|
||||||
@ -29,5 +30,15 @@
|
|||||||
time: Function.prototype.bind.call(console.time, console),
|
time: Function.prototype.bind.call(console.time, console),
|
||||||
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)
|
||||||
};
|
}
|
||||||
|
|
||||||
|
if (config && config.logLevel) {
|
||||||
|
Object.keys(logLevel).forEach(function(key,index) {
|
||||||
|
if (!config.logLevel.includes(key.toLocaleUpperCase())) {
|
||||||
|
logLevel[key] = function() {};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return logLevel;
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user