Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/assets/js/core/logger.js

23 lines
496 B
JavaScript
Raw Normal View History

2018-10-16 16:28:42 +00:00
let levels = ['error', 'warn', 'log', 'info'];
let level = 'warn';
function debug(method, ...args) {
if (levels.indexOf(method) <= levels.indexOf(level)) {
console[method](...args); // eslint-disable-line no-console
}
}
function namespace(ns) {
return levels.reduce(function(logger, method) {
logger[method] = debug.bind(console, method, ns);
return logger;
}, {});
}
debug.level = namespace.level = function(newLevel) {
level = newLevel;
};
export default namespace;