Skip to content

Commit

Permalink
check using name
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenyuLInx committed May 21, 2024
1 parent ac09c6d commit 24a7b7d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions dbt_common/events/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
from dbt_common.events.format import timestamp_to_datetime_string
from dbt_common.utils.encoding import ForgivingJSONEncoder

from dbt_common.events.types_pb2 import PrintEvent
PRINT_EVENT_NAME = "PrintEvent"


def _is_print_event(msg: EventMsg) -> bool:
return msg.info.name == PRINT_EVENT_NAME


# A Filter is a function which takes a BaseEvent and returns True if the event
# should be logged, False otherwise.
Expand Down Expand Up @@ -125,7 +130,7 @@ def write_line(self, msg: EventMsg):
# We send PrintEvent to logger as error so it goes to stdout
# when --quiet flag is set.
# --quiet flag will filter out all events lower than ERROR.
if isinstance(msg.data, PrintEvent):
if _is_print_event(msg):
level = "error"
else:
level = msg.info.level
Expand All @@ -148,9 +153,9 @@ def create_line(self, msg: EventMsg) -> str:

def create_info_line(self, msg: EventMsg) -> str:
scrubbed_msg: str = self.scrubber(msg.info.msg) # type: ignore
if isinstance(msg.data, PrintEvent):
if _is_print_event(msg):
# PrintEvent is a special case, we don't want to add a timestamp
return scrubbed_msg

ts: str = datetime.utcnow().strftime("%H:%M:%S")
return f"{self._get_color_tag()}{ts} {scrubbed_msg}"

Expand Down

0 comments on commit 24a7b7d

Please sign in to comment.