-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathutils.py
More file actions
18 lines (16 loc) · 629 Bytes
/
utils.py
File metadata and controls
18 lines (16 loc) · 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import logging
def _setup_debug_logger(name, level=logging.INFO, log_format=None):
# create logger with name provided
logger = logging.getLogger(name)
logger.setLevel(level)
# create file handler which logs even debug messages
fh = logging.FileHandler("%s.log" % name)
fh.setLevel(logging.DEBUG)
# create formatter and add it to the handlers
if not log_format:
log_format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
formatter = logging.Formatter(log_format)
fh.setFormatter(formatter)
# add the handlers to the logger
logger.addHandler(fh)
return logger