Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions socket_basics/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')}")
Expand Down
19 changes: 19 additions & 0 deletions tests/test_config_source.py
Original file line number Diff line number Diff line change
@@ -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