cloud-game/web/js/log.js
giongto35 7b736d455e
Merge Pr/173 with master (#218)
* Add the initial support for settings

* Rearrange init order for the settings and log modules

* Add import settings function

* Add initial settings display panel

* Add settings controls

* Add settings controls handlers

* Add garbage gui auto-builder for settings

* Add some custom binding handlers for settings

* Add super ineffective ¯\_(ツ)_/¯ keyboard bindings remap function

* Migrate keyboard to codes instead deprecated keyCodes

* Abort key remap on Esc

Co-authored-by: Sergey Stepanov <sergystepanov@gmail.com>
2020-07-04 04:24:13 +08:00

26 lines
784 B
JavaScript
Vendored

const log = (() => {
const levels = {'trace': 0, 'debug': 1, 'error': 2, 'warning': 3, 'info': 4};
let level = -1;
const atLeast = lv => (lv || -1) >= level;
return {
level: levels,
info: function () {
atLeast(levels.info) && console.info.apply(null, arguments)
},
debug: function () {
atLeast(levels.debug) && console.debug.apply(null, arguments)
},
error: function () {
console.error.apply(null, arguments)
},
warning: function () {
atLeast(levels.warning) && console.warn.apply(null, arguments)
},
setLevel: (level_) => {
level = levels[level_] || -1;
},
is: (level_) => level === level_
}
})(console);