forked from MLB-LED-Scoreboard/mlb-led-scoreboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.py
33 lines (24 loc) · 716 Bytes
/
debug.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
import data.scoreboard_config
import time
import sys
debug_enabled = False
time_format = "%H"
def set_debug_status(config):
global debug_enabled
debug_enabled = config.debug
global time_format
time_format = config.time_format
def __debugprint(text):
print(text)
sys.stdout.flush()
def log(text):
if debug_enabled:
__debugprint("DEBUG ({}): {}".format(__timestamp(), text))
def warning(text):
__debugprint("WARNING ({}): {}".format(__timestamp(), text))
def error(text):
__debugprint("ERROR ({}): {}".format(__timestamp(), text))
def info(text):
__debugprint("INFO ({}): {}".format(__timestamp(), text))
def __timestamp():
return time.strftime("{}:%M:%S".format(time_format), time.localtime())