mirror of
https://github.com/giongto35/cloud-game.git
synced 2026-07-22 17:47:11 +00:00
Log lines in the browser console
This commit is contained in:
parent
63d8a0354c
commit
3bbf075f92
2 changed files with 14 additions and 17 deletions
2
go.mod
2
go.mod
|
|
@ -28,7 +28,7 @@ require (
|
|||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/rs/xid v1.4.0 // indirect
|
||||
github.com/rs/xid v1.4.0
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/veandco/go-sdl2 v0.4.10
|
||||
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871
|
||||
|
|
|
|||
|
|
@ -3,24 +3,21 @@ const log = (() => {
|
|||
let level = -1;
|
||||
|
||||
const atLeast = lv => (lv || -1) >= level;
|
||||
const noop = () => ({});
|
||||
|
||||
const
|
||||
info = atLeast(levels.info) ? console.info.bind(window.console) : noop,
|
||||
debug = atLeast(levels.debug) ? console.debug.bind(window.console) : noop,
|
||||
error = atLeast(levels.error) ? console.error.bind(window.console) : noop,
|
||||
warning = atLeast(levels.warning) ? console.warn.bind(window.console) : noop;
|
||||
|
||||
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;
|
||||
},
|
||||
info,
|
||||
debug,
|
||||
error,
|
||||
warning,
|
||||
setLevel: (level_) => level = levels[level_] || -1,
|
||||
is: (level_) => level === level_
|
||||
}
|
||||
})(console);
|
||||
})(console, window);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue