-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.py
52 lines (41 loc) · 950 Bytes
/
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
# vim: set noet ts=4 sts=4 sw=4:
import colorlog
import logging
import sys
formatter = colorlog.ColoredFormatter(
'{log_color}{levelname:8}{reset} {message}',
datefmt=None,
style="{",
reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red',
}
)
l = logging.getLogger()
stream = logging.StreamHandler()
stream.setLevel(logging.DEBUG)
#Temporarily disable colorlog due to
# https://github.com/borntyping/python-colorlog/issues/36
#stream.setFormatter(formatter)
l = logging.getLogger()
l.setLevel(logging.INFO)
l.addHandler(stream)
sh_logger = logging.getLogger('sh')
sh_logger.setLevel(logging.WARN)
def info (s):
l.info(s)
def warn (s):
l.warning(s)
def error (s):
l.error(s)
def critical (s):
l.critical(s)
l.critical('')
l.critical('Critical error. Website NOT successfully built. Quitting.')
sys.exit(1)
def critical_leader (s):
l.critical(s)