root: set log level based on DEBUG flag

This commit is contained in:
Jens Langhammer 2020-05-09 20:53:47 +02:00
parent f700899640
commit 28b913136d
1 changed files with 9 additions and 6 deletions

View File

@ -96,6 +96,7 @@ INSTALLED_APPS = [
"passbook.providers.oidc.apps.PassbookProviderOIDCConfig", "passbook.providers.oidc.apps.PassbookProviderOIDCConfig",
"passbook.providers.saml.apps.PassbookProviderSAMLConfig", "passbook.providers.saml.apps.PassbookProviderSAMLConfig",
"passbook.providers.samlv2.apps.PassbookProviderSAMLv2Config", "passbook.providers.samlv2.apps.PassbookProviderSAMLv2Config",
"passbook.stages.identification.apps.PassbookStageIdentificationConfig",
"passbook.stages.otp.apps.PassbookStageOTPConfig", "passbook.stages.otp.apps.PassbookStageOTPConfig",
"passbook.stages.captcha.apps.PassbookStageCaptchaConfig", "passbook.stages.captcha.apps.PassbookStageCaptchaConfig",
"passbook.stages.password.apps.PassbookStagePasswordConfig", "passbook.stages.password.apps.PassbookStagePasswordConfig",
@ -327,17 +328,19 @@ LOGGING = {
}, },
"loggers": {}, "loggers": {},
} }
LOG_LEVEL = "DEBUG" if DEBUG else "WARNING"
_LOGGING_HANDLER_MAP = { _LOGGING_HANDLER_MAP = {
"": "DEBUG", "": LOG_LEVEL,
"passbook": "DEBUG", "passbook": LOG_LEVEL,
"django": "WARNING", "django": "WARNING",
"celery": "WARNING", "celery": "WARNING",
"grpc": "DEBUG", "grpc": LOG_LEVEL,
"oauthlib": "DEBUG", "oauthlib": LOG_LEVEL,
"oauth2_provider": "DEBUG", "oauth2_provider": LOG_LEVEL,
"oidc_provider": "DEBUG", "oidc_provider": LOG_LEVEL,
} }
for handler_name, level in _LOGGING_HANDLER_MAP.items(): for handler_name, level in _LOGGING_HANDLER_MAP.items():
# pyright: reportGeneralTypeIssues=false
LOGGING["loggers"][handler_name] = { LOGGING["loggers"][handler_name] = {
"handlers": ["console"], "handlers": ["console"],
"level": level, "level": level,