def initialise_logger(app):
"""
Read environment config then initialise a 2MB rotating log. Prod Log Level can be reduced to help diagnose Prod
only issues.
"""
log_dir = app.config['LOG_DIR']
log_level = app.config['LOG_LEVEL']
if not os.path.exists(log_dir):
os.makedirs(log_dir)
file_handler = RotatingFileHandler(log_dir + '/tasking-manager.log', 'a', 2 * 1024 * 1024, 3)
file_handler.setLevel(log_level)
file_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
app.logger.addHandler(file_handler)
app.logger.setLevel(log_level)
评论列表
文章目录