cloud-game/web/js/log.js
Sergey Stepanov 2bc64a3be8 Migrate from IIFE to modern ES modules
These modules should be supported by all contemporary browsers, and this transition should resolve most issues related to the explicit import order of the .js files.
2024-03-17 22:09:43 +03:00

31 lines
844 B
JavaScript

const noop = () => ({})
const _log = {
ASSERT: 1,
ERROR: 2,
WARN: 3,
INFO: 4,
DEBUG: 5,
TRACE: 6,
DEFAULT: 5,
set level(level) {
this.assert = level >= this.ASSERT ? console.assert.bind(window.console) : noop;
this.error = level >= this.ERROR ? console.error.bind(window.console) : noop;
this.warn = level >= this.WARN ? console.warn.bind(window.console) : noop;
this.info = level >= this.INFO ? console.info.bind(window.console) : noop;
this.debug = level >= this.DEBUG ? console.debug.bind(window.console) : noop;
this.trace = level >= this.TRACE ? console.log.bind(window.console) : noop;
this._level = level;
},
get level() {
return this._level;
}
}
_log.level = _log.DEFAULT;
/**
* Logging module.
*/
export const log = _log