-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.py
More file actions
33 lines (25 loc) · 861 Bytes
/
Copy pathlog.py
File metadata and controls
33 lines (25 loc) · 861 Bytes
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 logging
import json
def debug(obj):
"""
Print a JSON representation of the given object to the console, at debug level.
"""
if logging.getLogger().level == logging.DEBUG:
print(json.dumps(obj, indent=2, default=str))
def info(obj):
"""
Print a JSON representation of the given object to the console, at info level.
"""
if logging.getLogger().level <= logging.INFO:
print(json.dumps(obj, indent=2, default=str))
def warn(obj):
"""
Print a JSON representation of the given object to the console, at warn level.
"""
if logging.getLogger().level <= logging.WARNING:
print(json.dumps(obj, indent=2, default=str))
def error(obj):
"""
Print a JSON representation of the given object to the console, at error level.
"""
print(json.dumps(obj, indent=2, default=str))