Improve auto logging to enable logging to all apps, even those not calling the ready() method.
This commit is contained in:
@@ -53,18 +53,6 @@ class MayanAppConfig(apps.AppConfig):
|
||||
)
|
||||
),
|
||||
|
||||
if setting_auto_logging.value:
|
||||
if settings.DEBUG:
|
||||
level = 'DEBUG'
|
||||
else:
|
||||
level = 'INFO'
|
||||
|
||||
settings.LOGGING['loggers'][self.name] = {
|
||||
'handlers': ['console'],
|
||||
'propagate': True,
|
||||
'level': level,
|
||||
}
|
||||
|
||||
|
||||
class CommonApp(MayanAppConfig):
|
||||
app_url = ''
|
||||
@@ -150,3 +138,39 @@ class CommonApp(MayanAppConfig):
|
||||
user_locale_profile_session_config,
|
||||
dispatch_uid='user_locale_profile_session_config'
|
||||
)
|
||||
self.setup_auto_logging()
|
||||
|
||||
def setup_auto_logging(self):
|
||||
if setting_auto_logging.value:
|
||||
if settings.DEBUG:
|
||||
level = 'DEBUG'
|
||||
else:
|
||||
level = 'INFO'
|
||||
|
||||
loggers = {}
|
||||
for app in apps.apps.get_app_configs():
|
||||
loggers[app.name] = {
|
||||
'handlers': ['console'],
|
||||
'propagate': True,
|
||||
'level': level,
|
||||
}
|
||||
|
||||
logging.config.dictConfig(
|
||||
{
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'formatters': {
|
||||
'intermediate': {
|
||||
'format': '%(name)s <%(process)d> [%(levelname)s] "%(funcName)s() %(message)s"'
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'intermediate'
|
||||
}
|
||||
},
|
||||
'loggers': loggers
|
||||
}
|
||||
)
|
||||
|
||||
@@ -212,23 +212,6 @@ COMPRESS_CSS_FILTERS = (
|
||||
COMPRESS_ENABLED = False
|
||||
COMPRESS_PARSER = 'compressor.parser.HtmlParser'
|
||||
# --------- Django -------------------
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': True,
|
||||
'formatters': {
|
||||
'intermediate': {
|
||||
'format': '%(name)s <%(process)d> [%(levelname)s] "%(funcName)s() %(message)s"'
|
||||
},
|
||||
},
|
||||
'handlers': {
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
'formatter': 'intermediate'
|
||||
}
|
||||
},
|
||||
'loggers': {}
|
||||
}
|
||||
LOGIN_URL = 'authentication:login_view'
|
||||
LOGIN_REDIRECT_URL = 'common:home'
|
||||
INTERNAL_IPS = ('127.0.0.1',)
|
||||
|
||||
Reference in New Issue
Block a user