Skip to content

Commit

Permalink
Change AdapterRegistered event to dynamic log level
Browse files Browse the repository at this point in the history
  • Loading branch information
emmyoop committed Mar 29, 2024
1 parent 75f1b82 commit f5bc127
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion dbt/adapters/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dbt.adapters.events.base_types import (
DebugLevel,
DynamicLevel,
ErrorLevel,
InfoLevel,
WarnLevel,
Expand Down Expand Up @@ -281,7 +282,7 @@ def message(self) -> str:
# Skipping E032, E033, E034


class AdapterRegistered(InfoLevel):
class AdapterRegistered(DynamicLevel):
def code(self) -> str:
return "E034"

Expand Down
16 changes: 14 additions & 2 deletions dbt/adapters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, Dict, List, Optional, Set, Type

from dbt_common.events.functions import fire_event
from dbt_common.events.base_types import EventLevel
from dbt_common.exceptions import DbtInternalError, DbtRuntimeError
from dbt_common.semver import VersionSpecifier

Expand Down Expand Up @@ -96,11 +97,22 @@ def load_plugin(self, name: str) -> Type[Credentials]:

return plugin.credentials

def register_adapter(self, config: AdapterRequiredConfig, mp_context: SpawnContext) -> None:
def register_adapter(
self,
config: AdapterRequiredConfig,
mp_context: SpawnContext,
AdapterRegistered_log_level: EventLevel=EventLevel.INFO
) -> None:
adapter_name = config.credentials.type
adapter_type = self.get_adapter_class_by_name(adapter_name)
adapter_version = self._adapter_version(adapter_name)
fire_event(AdapterRegistered(adapter_name=adapter_name, adapter_version=adapter_version))
fire_event(
AdapterRegistered(
adapter_name=adapter_name,
adapter_version=adapter_version
),
level=AdapterRegistered_log_level
)
with self.lock:
if adapter_name in self.adapters:
# this shouldn't really happen...
Expand Down

0 comments on commit f5bc127

Please sign in to comment.