-
-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathLogLevels.cfc
109 lines (101 loc) · 1.99 KB
/
LogLevels.cfc
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Copyright Since 2005 ColdBox Framework by Luis Majano and Ortus Solutions, Corp
* www.ortussolutions.com
* ---
* The different logging levels available in LogBox. Log levels available in the this scope: OFF=-1, FATAL=0, ERROR=1, WARN=2, INFO=3, DEBUG=4
*
* @author Luis Majano <lmajano@ortussolutions.com>
*/
component {
// All Available Logging Levels for LogBox
this.OFF = -1;
this.FATAL = 0;
this.ERROR = 1;
this.WARN = 2;
this.INFO = 3;
this.DEBUG = 4;
// List of valid levels
this.VALIDLEVELS = "off,fatal,error,warn,info,debug";
// Max
this.MINLEVEL = -1;
this.MAXLEVEL = 4;
/**
* Lookup a level in our numeric enum, else it returns void.
*
* @level The numeric level
*/
function lookup( required level ){
switch ( level ) {
case -1:
return "OFF";
case 0:
return "FATAL";
case 1:
return "ERROR";
case 2:
return "WARN";
case 3:
return "INFO";
case 4:
return "DEBUG";
}
}
/**
* Lookup level in numeric format from a string. If not found a 999 is returned
*
* @level The string level
*/
function lookupAsInt( required level ){
switch ( level ) {
case "OFF":
return -1;
case "FATAL":
return 0;
case "ERROR":
return 1;
case "WARN":
return 2;
case "WARNING":
return 2;
case "INFO":
return 3;
case "INFORMATION":
return 3;
case "DEBUG":
return 4;
default:
return 999;
}
}
/**
* Lookup a CF level using a number
*
* @level Numeric level
*/
function lookupCF( required level ){
switch ( level ) {
case -1:
return "OFF";
case 0:
return "Fatal";
case 1:
return "Error";
case 2:
return "Warning";
case 3:
return "Information";
case 4:
return "Information";
default:
return "Information";
}
}
/**
* Verifies if a level is valid or not
*
* @level numeric level
*/
function isLevelValid( required level ){
return ( arguments.level gte this.MINLEVEL AND arguments.level lte this.MAXLEVEL );
}
}