-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger.js
52 lines (43 loc) · 1.01 KB
/
logger.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
44
45
46
47
48
49
50
51
52
const ExtensionUtils = imports.misc.extensionUtils;
const LOG_LEVELS = {
"OFF" : 0,
"FATAL": 1,
"ERROR": 2,
"WARN": 3,
"INFO": 4,
"DEBUG": 5,
"TRACE": 6,
"ALL": 7
};
function logContext(msg) {
log(`replaceme ${msg}`);
}
function getLogLevel() {
let settings = ExtensionUtils.getSettings();
let loggingLevel = settings.get_uint("log-level");
return loggingLevel;
}
function fatal(msg) {
if (getLogLevel() > LOG_LEVELS.OFF)
logContext(`[FATAL] ${msg}`);
}
function error(msg) {
if (getLogLevel() > LOG_LEVELS.FATAL)
logContext(`[ERROR] ${msg}`);
}
function warn(msg) {
if (getLogLevel() > LOG_LEVELS.ERROR)
logContext(`[WARN] ${msg}`);
}
function info(msg) {
if (getLogLevel() > LOG_LEVELS.WARN)
logContext(`[INFO] ${msg}`);
}
function debug(msg) {
if (getLogLevel() > LOG_LEVELS.INFO)
logContext(`[DEBUG] ${msg}`);
}
function trace(msg) {
if (getLogLevel() > LOG_LEVELS.DEBUG)
logContext(`[TRACE] ${msg}`);
}