-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathutils.py
More file actions
54 lines (43 loc) · 1.16 KB
/
utils.py
File metadata and controls
54 lines (43 loc) · 1.16 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
Simple logging helper functions
'''
from __future__ import print_function
class __LoggingParameters:
pass
__module = __LoggingParameters()
__module.min_log_level = 0
__module.log_levels = {
'DEBUG': 0,
'INFO': 1,
'WARN': 2,
'ERROR': 3,
}
def set_log_level(level):
'''
Sets the minimum log level that should be output
'''
if level in __module.log_levels.values():
__module.min_log_level = level
else:
LOG_ERROR('logging.py: Requested log level unsupported')
def LOG(level, msg):
'''
Backbone logging function
'''
# Check if level is one of the defaults
if level in __module.log_levels.keys():
# Check if the requested log level is greater than or equal to
# the minimum logging level
if __module.log_levels[level] >= __module.min_log_level:
print('[', level, ']: ', msg)
else:
# If the level is not a default level, always print it
print('[', level, ']: ', msg)
def LOG_ERROR(msg):
LOG('ERROR', msg)
def LOG_WARN(msg):
LOG('WARN', msg)
def LOG_INFO(msg):
LOG('INFO', msg)
def LOG_DEBUG(msg):
LOG('DEBUG', msg)