forked from taylorwwebb/emergent_symbols
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.py
36 lines (30 loc) · 824 Bytes
/
util.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
import logging
from colorlog import ColoredFormatter
import os
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)
formatter = ColoredFormatter(
"%(log_color)s[%(asctime)s] %(message)s",
# datefmt='%H:%M:%S.%f',
datefmt=None,
reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'white,bold',
'INFOV': 'cyan,bold',
'WARNING': 'yellow',
'ERROR': 'red,bold',
'CRITICAL': 'red,bg_white',
},
secondary_log_colors={},
style='%'
)
ch.setFormatter(formatter)
log = logging.getLogger('rn')
log.setLevel(logging.DEBUG)
log.handlers = [] # No duplicated handlers
log.propagate = False # workaround for duplicated logs in ipython
log.addHandler(ch)
def check_path(path):
if not os.path.exists(path):
os.mkdir(path)