You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cookie-api/cookie_api/logger.py

16 lines
426 B
Python

import sys
import logbook
def global_init(settings={}):
_logging_setting = settings.get("LOGGING", {"LEVEL": logbook.TRACE})
_log_file = _logging_setting.get("LOG_FILE")
_level = _logging_setting.get("LEVEL")
if _log_file is not None:
logbook.TimedRotatingFileHandler(_log_file, level=_level).push_application()
else:
logbook.StreamHandler(sys.stdout, level=_level).push_application()