hostnames registration application for I2P
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

26 lines
686 B

import logging
def get_logger(filename=None, log_level='debug'):
""" Prepare logger instance for our scripts """
LEVELS = {
'debug': logging.DEBUG,
'info': logging.INFO,
'warning': logging.WARNING,
'error': logging.ERROR,
'critical': logging.CRITICAL
}
level = LEVELS.get(log_level, logging.NOTSET)
format = '%(asctime)s %(module)s:%(lineno)d[%(process)d] %(levelname)s: %(message)s'
formatter = logging.Formatter(format)
logger = logging.getLogger(__name__)
logger.setLevel(level)
if filename:
handler = logging.WatchedFileHandler(filename)
else:
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger.addHandler(handler)
return logger