-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.py
55 lines (40 loc) · 1.12 KB
/
logger.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Set of utils for logging and debugging
from inspect import getframeinfo, stack
from pprint import pprint
VERBOSE = True
DEBUG = True
NOT_NOW = -1
MONITOR = dict()
def debuginfo(function_calls_before_now = 1):
caller = getframeinfo(stack()[function_calls_before_now][0])
return f"{caller.filename}({caller.lineno})"
def log_verbose(verbose_content):
global VERBOSE
if VERBOSE:
log(verbose_content)
def log_debug(debugging_content):
global DEBUG
if DEBUG:
log(debugging_content)
def log_pretty_data(data):
pprint(data)
def log_value(var_name, value, stack_layer=2):
location_id = debuginfo(stack_layer)
log_debug(f">>>\t@{location_id}:{var_name} = {value}")
def logg(data, log_level):
if log_level is NOT_NOW:
pass
else:
log(data)
def log(printable_data):
print(printable_data)
def track_var(var_name, reference):
log_value(var_name, reference, 3)
global MONITOR
MONITOR[var_name] = reference
def inspect_var(var_name):
pass
def inspect_var():
for var in MONITOR.keys():
log_debug(f"<<<\t{var}: {MONITOR[var]}")
input()