diff --git a/singer_sdk/metrics.py b/singer_sdk/metrics.py index 990285ae04..bfc4e641c4 100644 --- a/singer_sdk/metrics.py +++ b/singer_sdk/metrics.py @@ -15,8 +15,6 @@ import yaml -from singer_sdk.helpers._resources import get_package_files - if t.TYPE_CHECKING: from types import TracebackType @@ -392,23 +390,18 @@ def _load_yaml_logging_config(path: Traversable | Path) -> t.Any: # noqa: ANN40 return yaml.safe_load(f) -def _get_default_config() -> t.Any: # noqa: ANN401 - """Get a logging configuration. - - Returns: - A logging configuration. - """ - log_config_path = get_package_files("singer_sdk").joinpath("default_logging.yml") - return _load_yaml_logging_config(log_config_path) - - -def _setup_logging(config: t.Mapping[str, t.Any]) -> None: +def _setup_logging( + default_logging_config: dict[str, t.Any], + config: t.Mapping[str, t.Any], +) -> None: """Setup logging. Args: + default_logging_config: A default + :py:std:label:`Python logging configuration dictionary`. config: A plugin configuration dictionary. """ - logging.config.dictConfig(_get_default_config()) + logging.config.dictConfig(default_logging_config) config = config or {} metrics_log_level = config.get(METRICS_LOG_LEVEL_SETTING, "INFO").upper() diff --git a/singer_sdk/plugin_base.py b/singer_sdk/plugin_base.py index 1564558cfe..7ed505a72b 100644 --- a/singer_sdk/plugin_base.py +++ b/singer_sdk/plugin_base.py @@ -23,6 +23,7 @@ ) from singer_sdk.exceptions import ConfigValidationError from singer_sdk.helpers._classproperty import classproperty +from singer_sdk.helpers._resources import get_package_files from singer_sdk.helpers._secrets import SecretString, is_common_secret_key from singer_sdk.helpers._util import read_json_file from singer_sdk.helpers.capabilities import ( @@ -162,7 +163,7 @@ def __init__( if self._is_secret_config(k): config_dict[k] = SecretString(v) self._config = config_dict - metrics._setup_logging(self.config) # noqa: SLF001 + metrics._setup_logging(self.get_default_logging_config(), self.config) # noqa: SLF001 self.metrics_logger = metrics.get_metrics_logger() self._validate_config(raise_errors=validate_config) @@ -178,6 +179,15 @@ def setup_mapper(self) -> None: logger=self.logger, ) + def get_default_logging_config(self) -> t.Any: # noqa: ANN401, PLR6301 + """Get a default logging configuration for the plugin. + + Returns: + A logging configuration. + """ + log_config_path = get_package_files("singer_sdk") / "default_logging.yml" + return metrics._load_yaml_logging_config(log_config_path) # noqa: SLF001 + @property def mapper(self) -> PluginMapper: """Plugin mapper for this tap.