#logger.setLevel(logging.DEBUG)
# "Cached" configuration values
-_write_error_log = config.get("write_error_log")
-_error_log_cleanup = config.get("error_log_cleanup")
+_config = {
+ "write_error_log" : config.get("write_error_log")
+ "error_log_cleanup": config.get("error_log_cleanup")
+}
def add(domain: str, error: dict) -> None:
logger.debug("domain='%s',error[]='%s' - CALLED!", domain, type(error))
if blacklist.is_blacklisted(domain):
raise RuntimeError(f"domain='{domain}' is blacklisted but function was invoked")
- elif not _write_error_log:
+ elif not _config["write_error_log"]:
raise RuntimeError("Logging of errors is disabled but function was invoked")
logger.debug("error[]='%s' - BEFORE!", type(error))
])
# Cleanup old entries
- logger.debug("Purging old records (distance: %d)", _error_log_cleanup)
- database.cursor.execute("DELETE FROM error_log WHERE created < ?", [time.time() - _error_log_cleanup])
+ logger.debug("Purging old records (distance: %d)", _config["error_log_cleanup"])
+ database.cursor.execute("DELETE FROM error_log WHERE created < ?", [time.time() - _config["error_log_cleanup"]
+ ])
logger.debug("EXIT!")