From fd93ab6cd4ddd7e51c293ad85db50abfa185e0e3 Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Sat, 18 Sep 2021 01:29:43 -0300 Subject: [PATCH] Refatora logging config para verbose opt do dev --- sapl/settings.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sapl/settings.py b/sapl/settings.py index dd3ce9cd9..57ba76400 100644 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -320,10 +320,20 @@ FORM_RENDERER = 'django.forms.renderers.DjangoTemplates' # suprime texto de ajuda default do django-filter FILTERS_HELP_TEXT_FILTER = False +LOGGING_CONSOLE_VERBOSE = config('LOGGING_CONSOLE_VERBOSE', cast=bool, default=False) + LOGGING = { 'version': 1, 'disable_existing_loggers': False, + 'filters': { + 'require_debug_false': { + '()': 'django.utils.log.RequireDebugFalse', + }, + 'require_debug_true': { + '()': 'django.utils.log.RequireDebugTrue', + }, + }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s ' + host + ' %(pathname)s %(name)s:%(funcName)s:%(lineno)d %(message)s' @@ -336,8 +346,15 @@ LOGGING = { 'console': { 'level': 'INFO', 'class': 'logging.StreamHandler', + 'filters': ['require_debug_true'], 'formatter': 'simple', }, + 'console_verbose': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'filters': ['require_debug_true'], + 'formatter': 'verbose', + }, 'applogfile': { 'level': 'INFO', 'class': 'logging.handlers.RotatingFileHandler', @@ -349,8 +366,8 @@ LOGGING = { }, 'loggers': { 'sapl': { - 'handlers': ['applogfile'], - 'level': 'INFO', + 'handlers': ['applogfile'] + ['console_verbose'] if LOGGING_CONSOLE_VERBOSE else [], + 'level': 'DEBUG' if LOGGING_CONSOLE_VERBOSE else 'INFO', 'propagate': True, }, 'django': {