mirror of
https://github.com/zulip/zulip.git
synced 2025-10-23 04:52:12 +00:00
logging: Set up a different logger for each backend.
Adds a top-level logger in `settings.LOGGING` `zulip.auth` with the default handlers `DEFAULT_ZULIP_HANDLERS` and an extra hanlder that writes to `/var/log/zulip/auth.log`. Each auth backend uses it's own logger, `self.logger` which is in form 'zulip.auth.<backend name>'. This way it's clear which auth backend generated the log and is easier to look for all authentication logs in one file. Besides the above mentioned changes, `name` attribute is added to `ZulipAuthMixin` so that these logging kind of calls wouldn't raise any issues when logging is tried in a class without `name` attribute. Also in the tests we use a new way to check if logger calls are made i.e. we use `assertLogs` to test if something is logged. Thanks to Mateusz Mandera for the idea of having a seperate logger for auth backends and suggestion of using `assertLogs`.
This commit is contained in:
@@ -680,6 +680,7 @@ SOFT_DEACTIVATION_LOG_PATH = zulip_path("/var/log/zulip/soft_deactivation.log")
|
||||
TRACEMALLOC_DUMP_DIR = zulip_path("/var/log/zulip/tracemalloc")
|
||||
SCHEDULED_MESSAGE_DELIVERER_LOG_PATH = zulip_path("/var/log/zulip/scheduled_message_deliverer.log")
|
||||
RETENTION_LOG_PATH = zulip_path("/var/log/zulip/message_retention.log")
|
||||
AUTH_LOG_PATH = zulip_path("/var/log/zulip/auth.log")
|
||||
|
||||
# The EVENT_LOGS feature is an ultra-legacy piece of code, which
|
||||
# originally logged all significant database changes for debugging.
|
||||
@@ -753,6 +754,12 @@ LOGGING: Dict[str, Any] = {
|
||||
if not DEBUG_ERROR_REPORTING else []),
|
||||
'formatter': 'default'
|
||||
},
|
||||
'auth_file': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.handlers.WatchedFileHandler',
|
||||
'formatter': 'default',
|
||||
'filename': AUTH_LOG_PATH,
|
||||
},
|
||||
'console': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.StreamHandler',
|
||||
@@ -890,6 +897,10 @@ LOGGING: Dict[str, Any] = {
|
||||
'zerver.management.commands.deliver_scheduled_messages': {
|
||||
'level': 'DEBUG',
|
||||
},
|
||||
'zulip.auth': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': DEFAULT_ZULIP_HANDLERS + ['auth_file']
|
||||
},
|
||||
'zulip.ldap': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['console', 'ldap_file', 'errors_file'],
|
||||
|
Reference in New Issue
Block a user