-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogging.js
43 lines (35 loc) · 888 Bytes
/
logging.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class Log {
constructor(debug_enabled = false) {
this.debug_enabled = debug_enabled
}
error(msg) {
if(!this.log_at_level('error',msg)) {
window.alert("Error: "+msg)
}
}
debug(msg) {
if(this.debug_enabled) {
this.log_at_level('debug',msg)
}
}
debugdir(msg) {
if(this.debug_enabled) {
if(typeof console !== "undefined" && console["dir"]) {
this.log_at_level('dir',msg)
} else {
this.log_at_level('debug',msg)
}
}
}
log_at_level(level,msg) {
if(typeof console !== "undefined" && console[level]) {
console[level](msg)
return true
}
window.alert(level+": "+msg)
return false
}
}
var log = new Log()
export default log
//debug,info,warn,error