From 09e133a08c60c70b70119fbe3fc9cac80a440696 Mon Sep 17 00:00:00 2001 From: Ali Nawaz Date: Fri, 6 Dec 2024 21:42:57 +0500 Subject: [PATCH 1/2] chore: allow custom log formatter --- course_discovery/settings/kubernetes.py | 4 ++-- course_discovery/settings/production.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/course_discovery/settings/kubernetes.py b/course_discovery/settings/kubernetes.py index 5ba1c1256d..cf228aaa1d 100644 --- a/course_discovery/settings/kubernetes.py +++ b/course_discovery/settings/kubernetes.py @@ -25,8 +25,8 @@ def get_docker_logger_config(): 'disable_existing_loggers': False, 'formatters': { 'standard': { - 'format': '%(asctime)s %(levelname)s %(process)d ' - '[%(name)s] %(filename)s:%(lineno)d - %(message)s', + 'format': LOGGING_FORMAT_STRING or '%(asctime)s %(levelname)s %(process)d ' + '[%(name)s] %(filename)s:%(lineno)d - %(message)s' }, 'syslog_format': {'format': syslog_format}, 'raw': {'format': '%(message)s'}, diff --git a/course_discovery/settings/production.py b/course_discovery/settings/production.py index 44609c0bd0..237e0d60b8 100644 --- a/course_discovery/settings/production.py +++ b/course_discovery/settings/production.py @@ -24,6 +24,8 @@ # the values read from disk should UPDATE the pre-configured dicts. DICT_UPDATE_KEYS = ('JWT_AUTH',) +LOGGING_FORMAT_STRING = '' + # This may be overridden by the YAML in DISCOVERY_CFG, but it should be here as a default. MEDIA_STORAGE_BACKEND = {} From d4ce626bfda010125e1b288e79f47eddbe7e7e55 Mon Sep 17 00:00:00 2001 From: Ali Nawaz Date: Fri, 6 Dec 2024 22:39:54 +0500 Subject: [PATCH 2/2] refactor: move default to base settings --- course_discovery/settings/base.py | 1 + course_discovery/settings/kubernetes.py | 4 ++-- course_discovery/settings/production.py | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/course_discovery/settings/base.py b/course_discovery/settings/base.py index 76c79a6ac2..2d578ac255 100644 --- a/course_discovery/settings/base.py +++ b/course_discovery/settings/base.py @@ -328,6 +328,7 @@ # Set up logging for development use (logging to stdout) level = 'DEBUG' if DEBUG else 'INFO' hostname = platform.node().split(".")[0] +LOGGING_FORMAT_STRING = '' # Use a different address for Mac OS X syslog_address = '/var/run/syslog' if platform.system().lower() == 'darwin' else '/dev/log' diff --git a/course_discovery/settings/kubernetes.py b/course_discovery/settings/kubernetes.py index cf228aaa1d..01386c6fc0 100644 --- a/course_discovery/settings/kubernetes.py +++ b/course_discovery/settings/kubernetes.py @@ -25,8 +25,8 @@ def get_docker_logger_config(): 'disable_existing_loggers': False, 'formatters': { 'standard': { - 'format': LOGGING_FORMAT_STRING or '%(asctime)s %(levelname)s %(process)d ' - '[%(name)s] %(filename)s:%(lineno)d - %(message)s' + 'format': LOGGING_FORMAT_STRING or '%(asctime)s %(levelname)s %(process)d ' + '[%(name)s] %(filename)s:%(lineno)d - %(message)s' }, 'syslog_format': {'format': syslog_format}, 'raw': {'format': '%(message)s'}, diff --git a/course_discovery/settings/production.py b/course_discovery/settings/production.py index 237e0d60b8..44609c0bd0 100644 --- a/course_discovery/settings/production.py +++ b/course_discovery/settings/production.py @@ -24,8 +24,6 @@ # the values read from disk should UPDATE the pre-configured dicts. DICT_UPDATE_KEYS = ('JWT_AUTH',) -LOGGING_FORMAT_STRING = '' - # This may be overridden by the YAML in DISCOVERY_CFG, but it should be here as a default. MEDIA_STORAGE_BACKEND = {}