Skip to content

Commit 50ea125

Browse files
committed
support some logging options
1 parent de246c7 commit 50ea125

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

util/logging.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
LOG_LEVEL = 1
99

10-
def log(*msg):
10+
def log(*msg, **kwargs):
1111
import datetime
12-
print('[%s]' % datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), ' '.join([str(it) for it in msg]))
12+
sep = kwargs.get('sep', ' ')
13+
print('[%s]' % datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'), sep.join([str(it) for it in msg]))
1314

1415
def set_silence():
1516
global LOG_LEVEL
@@ -25,24 +26,24 @@ def is_debug_logged():
2526
def is_info_logged():
2627
return LOG_LEVEL <= 1
2728

28-
def debug(*msg):
29-
log_at_level(0, *msg)
29+
def debug(*msg, **kwargs):
30+
log_at_level(0, *msg, **kwargs)
3031

31-
def info(*msg):
32-
log_at_level(1, *msg)
32+
def info(*msg, **kwargs):
33+
log_at_level(1, *msg, **kwargs)
3334

34-
def warn(*msg):
35-
log_at_level(2, *msg)
35+
def warn(*msg, **kwargs):
36+
log_at_level(2, *msg, **kwargs)
3637

37-
def vlog(*msg):
38-
log_at_level(-1, *msg)
38+
def vlog(*msg, **kwargs):
39+
log_at_level(-1, *msg, **kwargs)
3940

40-
def vlog2(*msg):
41-
log_at_level(-2, *msg)
41+
def vlog2(*msg, **kwargs):
42+
log_at_level(-2, *msg, **kwargs)
4243

43-
def vlog3(*msg):
44-
log_at_level(-3, *msg)
44+
def vlog3(*msg, **kwargs):
45+
log_at_level(-3, *msg, **kwargs)
4546

46-
def log_at_level(level, *msg):
47+
def log_at_level(level, *msg, **kwargs):
4748
if level >= LOG_LEVEL:
48-
log(*msg)
49+
log(*msg, **kwargs)

0 commit comments

Comments
 (0)