Skip to content

Commit

Permalink
Discard changes to dbt_common/events/event_manager.py
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke authored May 29, 2024
1 parent b53640f commit 0841137
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions dbt_common/events/event_manager.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os
import traceback
from typing import Callable, List, Optional, Protocol, Tuple
from typing import List, Optional, Protocol, Tuple

from dbt_common.events.base_types import BaseEvent, EventLevel, msg_from_base_event, EventMsg
from dbt_common.events.base_types import BaseEvent, EventLevel, msg_from_base_event, TCallback
from dbt_common.events.logger import LoggerConfig, _Logger, _TextLogger, _JsonLogger, LineFormat


class EventManager:
def __init__(self) -> None:
self.loggers: List[_Logger] = []
self.callbacks: List[Callable[[EventMsg], None]] = []
self.callbacks: List[TCallback] = []

def fire_event(self, e: BaseEvent, level: Optional[EventLevel] = None) -> None:
msg = msg_from_base_event(e, level=level)
Expand Down Expand Up @@ -37,13 +37,16 @@ def add_logger(self, config: LoggerConfig) -> None:
)
self.loggers.append(logger)

def add_callback(self, callback: TCallback) -> None:
self.callbacks.append(callback)

def flush(self) -> None:
for logger in self.loggers:
logger.flush()


class IEventManager(Protocol):
callbacks: List[Callable[[EventMsg], None]]
callbacks: List[TCallback]
loggers: List[_Logger]

def fire_event(self, e: BaseEvent, level: Optional[EventLevel] = None) -> None:
Expand All @@ -52,6 +55,9 @@ def fire_event(self, e: BaseEvent, level: Optional[EventLevel] = None) -> None:
def add_logger(self, config: LoggerConfig) -> None:
...

def add_callback(self, callback: TCallback) -> None:
...


class TestEventManager(IEventManager):
__test__ = False
Expand Down

0 comments on commit 0841137

Please sign in to comment.