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()