blob: cd2a0f1d0fab3a0a376b81f5a50b150e2285aa00 (
plain) (
blame)
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
|
from __future__ import print_function
import logging
import sys
def abort(msg, exitcode=1):
print(msg, file=sys.stderr)
sys.exit(exitcode)
def standard_logger(name, debug):
if not debug:
return logging.getLogger(name)
return debug_logger(name)
def debug_logger(name):
log_format = '%(asctime)-15s %(levelname)-6s %(message)s'
date_format = '%b %d %H:%M:%S'
formatter = logging.Formatter(fmt=log_format, datefmt=date_format)
handler = logging.StreamHandler(stream=sys.stdout)
handler.setFormatter(formatter)
logger = logging.getLogger(name)
logger.setLevel(logging.DEBUG)
logger.addHandler(handler)
return logger
|