MagicMirror/js/logger.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-03-24 17:19:32 +01:00
/* Magic Mirror
* Logger
2020-05-03 18:59:26 +02:00
* This logger is very simple, but needs to be extended.
* This system can eventually be used to push the log messages to an external target.
2016-03-24 17:19:32 +01:00
*
2020-04-28 23:05:28 +02:00
* By Michael Teeuw https://michaelteeuw.nl
2016-03-24 17:19:32 +01:00
* MIT Licensed.
*/
2020-05-11 07:22:40 +02:00
(function (root, factory) {
if (typeof exports === 'object') {
2020-05-11 07:23:21 +02:00
// add timestamps in front of log messages
require("console-stamp")(console, "yyyy-mm-dd HH:MM:ss.l");
2020-05-11 07:22:40 +02:00
// Node, CommonJS-like
module.exports = factory(root.config);
} else {
// Browser globals (root is window)
root.Log = factory(root.config);
}
}(this, function (config) {
2016-03-24 17:19:32 +01:00
return {
info: Function.prototype.bind.call(console.info, console),
log: Function.prototype.bind.call(console.log, console),
error: Function.prototype.bind.call(console.error, console),
warn: Function.prototype.bind.call(console.warn, console),
group: Function.prototype.bind.call(console.group, console),
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)
2016-03-24 17:19:32 +01:00
};
2020-05-11 07:22:40 +02:00
}));