From 7233841171677aac6f584ea026af613337538581 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 17 Nov 2023 18:40:09 +0000 Subject: [PATCH] analytics: Move logging config into LOGGING, use "zulip.analytics". This should not reuse (and reconfigure!) the "zulip.management" logger. --- analytics/lib/counts.py | 6 ++---- zproject/computed_settings.py | 10 ++++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/analytics/lib/counts.py b/analytics/lib/counts.py index 2d1fb206d7..8b62017253 100644 --- a/analytics/lib/counts.py +++ b/analytics/lib/counts.py @@ -19,7 +19,6 @@ from analytics.models import ( UserCount, installation_epoch, ) -from zerver.lib.logging_util import log_to_file from zerver.lib.timestamp import ceiling_to_day, ceiling_to_hour, floor_to_hour, verify_UTC from zerver.models import Message, Realm, RealmAuditLog, Stream, UserActivityInterval, UserProfile @@ -31,10 +30,9 @@ if settings.ZILENCER_ENABLED: RemoteZulipServer, ) -## Logging setup ## -logger = logging.getLogger("zulip.management") -log_to_file(logger, settings.ANALYTICS_LOG_PATH) +logger = logging.getLogger("zulip.analytics") + # You can't subtract timedelta.max from a datetime, so use this instead TIMEDELTA_MAX = timedelta(days=365 * 1000) diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py index 2aa7fed300..90c7b54767 100644 --- a/zproject/computed_settings.py +++ b/zproject/computed_settings.py @@ -763,6 +763,12 @@ LOGGING: Dict[str, Any] = { else [] ), }, + "analytics_file": { + "level": "DEBUG", + "class": "logging.handlers.WatchedFileHandler", + "formatter": "default", + "filename": ANALYTICS_LOG_PATH, + }, "auth_file": { "level": "DEBUG", "class": "logging.handlers.WatchedFileHandler", @@ -929,6 +935,10 @@ LOGGING: Dict[str, Any] = { "zerver.management.commands.deliver_scheduled_messages": { "level": "DEBUG", }, + "zulip.analytics": { + "handlers": ["analytics_file", "errors_file"], + "propagate": False, + }, "zulip.auth": { "level": "DEBUG", "handlers": [*DEFAULT_ZULIP_HANDLERS, "auth_file"],