-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLogging.js
More file actions
33 lines (29 loc) · 1.07 KB
/
Logging.js
File metadata and controls
33 lines (29 loc) · 1.07 KB
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
export const DEBUG_LEVEL_NONE = 0;
export const DEBUG_LEVEL_ERROR = 1;
export const DEBUG_LEVEL_WARN = 2;
export const DEBUG_LEVEL_INFO = 3;
export const DEBUG_LEVEL_DEBUG = 4;
export const DEBUG_LEVEL_VERBOSE = 5;
export var logging = {
error: console.error,
warn: console.warn,
info: console.log,
debug: console.log,
verbose: function (...msg) {},
};
export function setLoggingLevel(level) {
logging.error = level >= 1 ? console.error : function (...msg) {};
logging.warn = level >= 2 ? console.warn : function (...msg) {};
logging.info = level >= 3 ? console.log : function (...msg) {};
logging.debug = level >= 4 ? console.log : function (...msg) {};
logging.verbose = level >= 5 ? console.log : function (...msg) {};
}
if (window) {
window.DEBUG_LEVEL_NONE = DEBUG_LEVEL_NONE;
window.DEBUG_LEVEL_ERROR = DEBUG_LEVEL_ERROR;
window.DEBUG_LEVEL_WARN = DEBUG_LEVEL_WARN;
window.DEBUG_LEVEL_INFO = DEBUG_LEVEL_INFO;
window.DEBUG_LEVEL_DEBUG = DEBUG_LEVEL_DEBUG;
window.DEBUG_LEVEL_VERBOSE = DEBUG_LEVEL_VERBOSE;
window.setLoggingLevel = setLoggingLevel;
}