diff --git a/singer_sdk/metrics.py b/singer_sdk/metrics.py index 23e86fd6b..1b4612023 100644 --- a/singer_sdk/metrics.py +++ b/singer_sdk/metrics.py @@ -394,21 +394,25 @@ def _load_yaml_logging_config(path: Traversable | Path) -> t.Any: # noqa: ANN40 return yaml.safe_load(f) -def _get_default_config_path(package_name: str) -> Traversable: +def _get_default_config_path(package: str) -> Traversable: """Get a logging configuration. Args: - package_name: The package name to get the logging configuration for. + package: The package name to get the logging configuration for. Returns: A logging configuration. """ filename = "default_logging.yml" - path = get_package_files(package_name) / filename + path = get_package_files(package) / filename return path if path.is_file() else get_package_files("singer_sdk") / filename -def _setup_logging(package: str, config: t.Mapping[str, t.Any]) -> None: +def _setup_logging( + config: t.Mapping[str, t.Any], + *, + package: str | None = None, +) -> None: """Setup logging. Args: diff --git a/singer_sdk/plugin_base.py b/singer_sdk/plugin_base.py index 68780a4ed..b88559088 100644 --- a/singer_sdk/plugin_base.py +++ b/singer_sdk/plugin_base.py @@ -162,7 +162,10 @@ def __init__( if self._is_secret_config(k): config_dict[k] = SecretString(v) self._config = config_dict - metrics._setup_logging(__package__, self.config) # noqa: SLF001 + metrics._setup_logging( # noqa: SLF001 + self.config, + package=self.__module__.split(".", maxsplit=1)[0], + ) self.metrics_logger = metrics.get_metrics_logger() self._validate_config(raise_errors=validate_config)