From e188d70b552be014c627494ab534e8ca1e2e48aa Mon Sep 17 00:00:00 2001 From: lelia <2418071+lelia@users.noreply.github.com> Date: Fri, 26 Jun 2026 17:50:16 -0400 Subject: [PATCH] feat(config): log config source Log the selected configuration source during Config initialization. --- socket_basics/core/config.py | 14 ++++++++++++-- tests/test_config_source.py | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/test_config_source.py diff --git a/socket_basics/core/config.py b/socket_basics/core/config.py index 55512cf..91876a8 100644 --- a/socket_basics/core/config.py +++ b/socket_basics/core/config.py @@ -43,9 +43,19 @@ def __init__(self, config_dict: Dict[str, Any] | None = None, json_config_path: self._config = merge_json_and_env_config() self._config = self._config - - # DEBUG: Log final configuration values + + # Log where the configuration is being loaded from logger = logging.getLogger(__name__) + config_source = self._config.get('_config_source', 'environment') + source_descriptions = { + 'api': 'Socket dashboard (API)', + 'json_file': 'JSON config file (--config)', + 'environment': 'environment variables', + } + source_desc = source_descriptions.get(config_source, config_source) + logger.info(f"Configuration loaded from: {source_desc}") + + # DEBUG: Log final configuration values logger.debug("Final Config object created with key values:") logger.debug(f" javascript_sast_enabled: {self._config.get('javascript_sast_enabled')}") logger.debug(f" socket_tier_1_enabled: {self._config.get('socket_tier_1_enabled')}") diff --git a/tests/test_config_source.py b/tests/test_config_source.py new file mode 100644 index 0000000..4c02455 --- /dev/null +++ b/tests/test_config_source.py @@ -0,0 +1,19 @@ +import logging + +from socket_basics.core.config import Config + + +def test_config_logs_default_environment_source(caplog, tmp_path): + caplog.set_level(logging.INFO, logger="socket_basics.core.config") + + Config({"workspace": str(tmp_path)}) + + assert "Configuration loaded from: environment variables" in caplog.text + + +def test_config_logs_named_source(caplog, tmp_path): + caplog.set_level(logging.INFO, logger="socket_basics.core.config") + + Config({"workspace": str(tmp_path), "_config_source": "api"}) + + assert "Configuration loaded from: Socket dashboard (API)" in caplog.text