-
Notifications
You must be signed in to change notification settings - Fork 5
/
debug.js
91 lines (66 loc) · 2.07 KB
/
debug.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
* webMethods.io CLI
* Copyright 2022 Software AG
* Apache-2.0
*/
const white = "\x1b[37m";
const Dim = "\x1b[2m";
const Reset = "\x1b[0m";
const Green = "\x1b[32m";
const Red = "\x1b[31m";
const Cyan = "\x1b[36m";
const Yellow = "\x1b[33m"
const lvl_permanent = -1;
const lvl_off = 0;
const lvl_error = 1;
const lvl_warning = 2;
const lvl_info = 3;
const lvl_debug = 4;
var defaultLevel = 0;
activeLevel = 0;
const prefix ="<WMIOCLI>";
function enableDebug(){
// console.log(Yellow + "ENABLED DEBUG" + Reset );
setLogLevel(lvl_debug);
}
function setLogLevel(inLevel){
activeLevel = inLevel;
// console.log(Yellow + "SETTING ACTIVE LEVEL TO: " + inLevel );
// console.log(Yellow + "SETTING: " + activeLevel );
}
function message(inMessage,level)
{
// console.log(Green + "DEBUG Level:" + level + Reset );
var message = inMessage;
if(level==undefined)level = 4;
if(level==lvl_permanent)console.log(message);
else
{
// console.log(Green + "Using Level:" + level + Reset );
// console.log(Green + "Defau Level:" + defaultLevel + Reset );
if(level>activeLevel)return;
switch (level)
{
case lvl_off:
//Nothing to do
break;
case lvl_debug:
message = Dim + "DEBUG:" + prefix +":"+ inMessage + Reset;
console.log(message);
break;
case lvl_info:
message = white + "INFO:" + prefix +":"+ inMessage + Reset;
console.log(message);
break;
case lvl_warning:
message = Yellow + "WARN:" + prefix +":"+ inMessage + Reset;
console.log(message);
break;
case lvl_error:
message = Red + "ERROR:" + prefix + inMessage + Reset;
console.log(message);
break;
}
}
}
module.exports = { enableDebug, message, setLogLevel };