-
Notifications
You must be signed in to change notification settings - Fork 3
/
log.py
34 lines (22 loc) · 844 Bytes
/
log.py
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
#!/usr/bin/python3
"""
Log functions
"""
import sys
import toolbox
PREFIX = 'roberta:'
QUIET = toolbox.enabled_in_env('LUX_QUIET')
def print_err(*value, sep=' ', end='\n', flush=False):
"""Prints the values to stderr."""
if QUIET:
return
print(*value, sep=sep, end=end, file=sys.stderr, flush=flush)
def log(*value, sep=' ', end='\n', flush=False):
"""Prints the values to stderr with prefix."""
print_err(PREFIX, *value, sep=sep, end=end, flush=flush)
def log_err(*value, sep=' ', end='\n', flush=False):
"""Prints the values to stderr with prefix and 'error:'"""
log('error:', *value, sep=sep, end=end, flush=flush)
def log_warn(*value, sep=' ', end='\n', flush=False):
"""Prints the values to stderr with prefix and 'warning:'"""
log('warning:', *value, sep=sep, end=end, flush=flush)