From 0693d8bbf25693883280f571f4021f197279b29e Mon Sep 17 00:00:00 2001 From: Akiff Manji Date: Thu, 25 Apr 2024 23:40:56 +0000 Subject: [PATCH 1/4] fix: fixes a regression that requires a log file in multi-tenant mode Signed-off-by: Akiff Manji --- aries_cloudagent/config/logging.py | 32 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/aries_cloudagent/config/logging.py b/aries_cloudagent/config/logging.py index 98080c31fc..2f78f6925e 100644 --- a/aries_cloudagent/config/logging.py +++ b/aries_cloudagent/config/logging.py @@ -163,27 +163,37 @@ def configure( enabled """ + write_to_log_file = log_file is not None or log_file == "" + if multitenant: + # The default logging config for multi-tenant mode specifies a log file + # location if --log-file is specified on startup and a config file is not. + if not log_config_path and write_to_log_file: + log_config_path = cls.default_multitenant_config_path_ini + cls._configure_multitenant_logging( - log_config_path=log_config_path - or DEFAULT_MULTITENANT_LOGGING_CONFIG_PATH_INI, + log_config_path=log_config_path, log_level=log_level, - log_file=log_file, + log_file=log_file, ) else: + # The default config for single-tenant mode does not specify a log file + # location. This is a check that requires a log file path to be provided if + # --log-file is specified on startup and a config file is not. + if not log_config_path and write_to_log_file and not log_file: + raise ValueError( + "log_file (--log-file) must be provided in single-tenant mode " + "using the default config since a log file path is not set." + ) + cls._configure_logging( - log_config_path=log_config_path or DEFAULT_LOGGING_CONFIG_PATH_INI, + log_config_path=log_config_path or cls.default_config_path_ini, log_level=log_level, log_file=log_file, ) @classmethod def _configure_logging(cls, log_config_path, log_level, log_file): - if log_file is not None and log_file == "": - raise ValueError( - "log_file (--log-file) must be provided in singletenant mode." - ) - # Setup log config and log file if provided cls._setup_log_config_file(log_config_path, log_file) @@ -199,10 +209,6 @@ def _configure_logging(cls, log_config_path, log_level, log_file): @classmethod def _configure_multitenant_logging(cls, log_config_path, log_level, log_file): - # Unlike in singletenant mode, the defualt config for multitenant mode - # specifies a default log_file if one is not explicitly provided - # so we don't need the same check here - # Setup log config and log file if provided cls._setup_log_config_file(log_config_path, log_file) From b6474f1738be9f7ae6dc4af1e3afcad35aefb133 Mon Sep 17 00:00:00 2001 From: Akiff Manji Date: Thu, 25 Apr 2024 23:47:38 +0000 Subject: [PATCH 2/4] fix: formatting Signed-off-by: Akiff Manji --- aries_cloudagent/config/logging.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aries_cloudagent/config/logging.py b/aries_cloudagent/config/logging.py index 2f78f6925e..247b73b0ae 100644 --- a/aries_cloudagent/config/logging.py +++ b/aries_cloudagent/config/logging.py @@ -170,15 +170,15 @@ def configure( # location if --log-file is specified on startup and a config file is not. if not log_config_path and write_to_log_file: log_config_path = cls.default_multitenant_config_path_ini - + cls._configure_multitenant_logging( log_config_path=log_config_path, log_level=log_level, - log_file=log_file, + log_file=log_file, ) else: # The default config for single-tenant mode does not specify a log file - # location. This is a check that requires a log file path to be provided if + # location. This is a check that requires a log file path to be provided if # --log-file is specified on startup and a config file is not. if not log_config_path and write_to_log_file and not log_file: raise ValueError( From f9eaddf8f10ac385165dea086d912d7c5cc65883 Mon Sep 17 00:00:00 2001 From: Akiff Manji Date: Thu, 25 Apr 2024 23:51:52 +0000 Subject: [PATCH 3/4] fix: change log file name in default config Signed-off-by: Akiff Manji --- aries_cloudagent/config/default_multitenant_logging_config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aries_cloudagent/config/default_multitenant_logging_config.ini b/aries_cloudagent/config/default_multitenant_logging_config.ini index 2c799198f1..f435e80da4 100644 --- a/aries_cloudagent/config/default_multitenant_logging_config.ini +++ b/aries_cloudagent/config/default_multitenant_logging_config.ini @@ -21,7 +21,7 @@ args = (sys.stderr,) class = logging.handlers.TimedRotatingFileMultiProcessHandler level = DEBUG formatter = formatter -args = ('test.log', 'd', 7, 1) +args = ('agent.log', 'd', 7, 1) [formatter_formatter] format = %(asctime)s %(wallet_id)s %(levelname)s %(pathname)s:%(lineno)d %(message)s From 4a699f3527ed0a9157e243b1867585432844a31e Mon Sep 17 00:00:00 2001 From: Akiff Manji Date: Fri, 26 Apr 2024 16:38:59 +0000 Subject: [PATCH 4/4] fix: failing integration tests Signed-off-by: Akiff Manji --- aries_cloudagent/config/logging.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/aries_cloudagent/config/logging.py b/aries_cloudagent/config/logging.py index 247b73b0ae..174c5d1bb8 100644 --- a/aries_cloudagent/config/logging.py +++ b/aries_cloudagent/config/logging.py @@ -168,8 +168,13 @@ def configure( if multitenant: # The default logging config for multi-tenant mode specifies a log file # location if --log-file is specified on startup and a config file is not. - if not log_config_path and write_to_log_file: - log_config_path = cls.default_multitenant_config_path_ini + # When all else fails, the default single-tenant config file is used. + if not log_config_path: + log_config_path = ( + cls.default_multitenant_config_path_ini + if write_to_log_file + else cls.default_config_path_ini + ) cls._configure_multitenant_logging( log_config_path=log_config_path,