Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle exec info #4168

Merged
merged 2 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions core/dbt/events/functions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import dbt.logger as logger # type: ignore # TODO eventually remove dependency on this logger
from dbt.events.history import EVENT_HISTORY
from dbt.events.types import CliEventABC, Event
from dbt.events.types import CliEventABC, Event, ShowException


# top-level method for accessing the new eventing system
Expand All @@ -11,17 +11,53 @@
def fire_event(e: Event) -> None:
EVENT_HISTORY.append(e)
if isinstance(e, CliEventABC):
if e.level_tag() == 'test':
if e.level_tag() == 'test' and not isinstance(e, ShowException):
# TODO after implmenting #3977 send to new test level
logger.GLOBAL_LOGGER.debug(logger.timestamped_line(e.cli_msg()))
elif e.level_tag() == 'debug':
elif e.level_tag() == 'test' and isinstance(e, ShowException):
# TODO after implmenting #3977 send to new test level
logger.GLOBAL_LOGGER.debug(
logger.timestamped_line(e.cli_msg()),
exc_info=e.exc_info,
stack_info=e.stack_info,
extra=e.extra
)
elif e.level_tag() == 'debug' and not isinstance(e, ShowException):
logger.GLOBAL_LOGGER.debug(logger.timestamped_line(e.cli_msg()))
elif e.level_tag() == 'info':
elif e.level_tag() == 'debug' and isinstance(e, ShowException):
logger.GLOBAL_LOGGER.debug(
logger.timestamped_line(e.cli_msg()),
exc_info=e.exc_info,
stack_info=e.stack_info,
extra=e.extra
)
elif e.level_tag() == 'info' and not isinstance(e, ShowException):
logger.GLOBAL_LOGGER.info(logger.timestamped_line(e.cli_msg()))
elif e.level_tag() == 'warn':
elif e.level_tag() == 'info' and isinstance(e, ShowException):
logger.GLOBAL_LOGGER.info(
logger.timestamped_line(e.cli_msg()),
exc_info=e.exc_info,
stack_info=e.stack_info,
extra=e.extra
)
elif e.level_tag() == 'warn' and not isinstance(e, ShowException):
logger.GLOBAL_LOGGER.warning()(logger.timestamped_line(e.cli_msg()))
nathaniel-may marked this conversation as resolved.
Show resolved Hide resolved
elif e.level_tag() == 'error':
elif e.level_tag() == 'warn' and isinstance(e, ShowException):
logger.GLOBAL_LOGGER.warning(
logger.timestamped_line(e.cli_msg()),
exc_info=e.exc_info,
stack_info=e.stack_info,
extra=e.extra
)
elif e.level_tag() == 'error' and not isinstance(e, ShowException):
logger.GLOBAL_LOGGER.error(logger.timestamped_line(e.cli_msg()))
elif e.level_tag() == 'error' and isinstance(e, ShowException):
logger.GLOBAL_LOGGER.error(
logger.timestamped_line(e.cli_msg()),
exc_info=e.exc_info,
stack_info=e.stack_info,
extra=e.extra
)
else:
raise AssertionError(
f"Event type {type(e).__name__} has unhandled level: {e.level_tag()}"
Expand Down
8 changes: 8 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from abc import ABCMeta, abstractmethod
from dataclasses import dataclass
from typing import Any


# types to represent log levels
Expand Down Expand Up @@ -30,6 +31,13 @@ def level_tag(self) -> str:
return "error"


@dataclass
class ShowException():
exc_info: Any = None
stack_info: Any = None
extra: Any = None


# The following classes represent the data necessary to describe a
# particular event to both human readable logs, and machine reliable
# event streams. classes extend superclasses that indicate what
Expand Down