forked from mickeyperlstein/logging_debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
24 lines (17 loc) · 807 Bytes
/
__init__.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
import logging
def show_dict_fields(prefix, dict1):
for fld,val in dict1.items():
print('%s%s=%s' %(prefix, fld,val) )
def show_log(k,v):
if not isinstance(v, logging.PlaceHolder):
print('+ [%s] {%s} {%s} ' % (str.ljust( k, 20) , str(v.__class__)[8:-2], logging.getLevelName(v.level)) )
print(str.ljust( '-------------------------',20) )
show_dict_fields(' -',v.__dict__)
for h in v.handlers:
print(' +++%s {%s}' %(str(h.__class__)[8:-2], logging.getLevelName(h.level) ))
show_dict_fields(' -',h.__dict__)
def show_logs_and_handlers():
show_log('root',logging.getLogger(''))
for k,v in logging.Logger.manager.loggerDict.items() :
show_log(k,v)
show_logs_and_handlers()