-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathGxLogger.bbj
110 lines (106 loc) · 3.66 KB
/
GxLogger.bbj
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
110
rem package BBjGridExWidget
rem /**
rem * This file is part of the BBjGridExWidget plugin.
rem * (c) Basis Europe <eu@basis.cloud>
rem *
rem * For the full copyright and license information, please view the LICENSE
rem * file that was distributed with this source code.
rem */
rem /**
rem /**
rem * A logger class which is used internally to output log , warn , error messages to the console
rem * and to the debug.log file
rem *
rem * @author Hyyan Abo Fakher
rem */
class public GxLogger
rem /**
rem * When true , the logger will not output messages in the console
rem */
field public static BBjNumber SuppressConsole! = 1
rem /**
rem * When true , the logger will not output messages in debug file
rem */
field public static BBjNumber SuppressDebugFile! = 0
rem /**
rem * Constant value to define "info" log messages
rem *
rem * @return BBjString
rem */
method public static BBjString INFO()
methodret "INFO"
methodend
rem /**
rem * Constant value to define "warning" log messages
rem *
rem * @return BBjString
rem */
method public static BBjString WARNING()
methodret "WARNING"
methodend
rem /**
rem * Output a log message on the console and Debug.log file
rem *
rem * @param BBjString type! The log type
rem * @param BBjNumber section! The log section
rem * @param BBjString message The log message
rem *
rem * @return BBjString The final formatted message
rem */
method public static BBjString log(BBjString type!, BBjString section!, BBjString message!)
wrappedSection! = ""
if(section! <> null() and section!.length())
wrappedSection! = String.format("(%s)" , section!)
fi
output! = String.format("[BBjGridExWidget]%s - %s: %s", wrappedSection!, type!, message!)
if(!GxLogger.getSuppressDebugFile())
System.out.println(output!)
fi
if(!GxLogger.getSuppressConsole() and type! <> GxLogger.INFO())
print 'SHOW', output!
fi
methodret output!
methodend
rem /**
rem * Output a log message on the console and Debug.log file
rem *
rem * @param BBjNumber section! The log section
rem * @param BBjString message The log message
rem *
rem * @return BBjString The final formatted message
rem */
method public static BBjString log(BBjString section!, BBjString message!)
methodret GxLogger.log(GxLogger.INFO(), section! , message!)
methodend
rem /**
rem * Output a log message on the console and Debug.log file
rem *
rem * @param BBjString message The log message
rem *
rem * @return BBjString The final formatted message
rem */
method public static BBjString log(BBjString message!)
methodret GxLogger.log(null() , message!)
methodend
rem /**
rem * Output a warning message on the console and Debug.log file
rem *
rem * @param BBjNumber section! The log section
rem * @param BBjString message The log message
rem *
rem * @return BBjString The final formatted message
rem */
method public static BBjString warn(BBjString section!, BBjString message!)
methodret GxLogger.log(GxLogger.WARNING(), section! , message!)
methodend
rem /**
rem * Output a warning message on the console and Debug.log file
rem *
rem * @param BBjString message The log message
rem *
rem * @return BBjString The final formatted message
rem */
method public static BBjString warn(BBjString message!)
methodret GxLogger.log(GxLogger.WARNING(), null() , message!)
methodend
classend