Add auto logging.
This commit is contained in:
@@ -305,6 +305,14 @@ processing. This allows API users to have the document id of the document
|
||||
just uploaded and perform other actions on it while it becomes ready
|
||||
for access.
|
||||
|
||||
Auto logging
|
||||
------------
|
||||
App logging to the console is now automatically enabled. If Django's DEBUG
|
||||
flag is `True` the default level for auto logging is `DEBUG`. If Django's
|
||||
DEBUG flag is `False` (as in production), the default level changes to `INFO`.
|
||||
This should make it easier to add relevant messages to issue tickets as
|
||||
well as a adecuate logging during production.
|
||||
|
||||
Other changes
|
||||
-------------
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ from .links import (
|
||||
)
|
||||
from .literals import DELETE_STALE_UPLOADS_INTERVAL
|
||||
from .menus import menu_facet, menu_main, menu_secondary, menu_tools
|
||||
from .settings import setting_auto_logging
|
||||
from .tasks import task_delete_stale_uploads # NOQA - Force task registration
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -52,6 +53,18 @@ 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 = ''
|
||||
|
||||
@@ -28,3 +28,10 @@ setting_paginate_by = namespace.add_setting(
|
||||
'An integer specifying how many objects should be displayed per page.'
|
||||
)
|
||||
)
|
||||
setting_auto_logging = namespace.add_setting(
|
||||
global_name='COMMON_AUTO_LOGGING',
|
||||
default=True,
|
||||
help_text=_(
|
||||
'Automatically enable logging to all apps.'
|
||||
)
|
||||
)
|
||||
|
||||
@@ -212,6 +212,23 @@ 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