diff --git a/core/dbt/context/base.py b/core/dbt/context/base.py index 4bc47000716..f3b82324fbb 100644 --- a/core/dbt/context/base.py +++ b/core/dbt/context/base.py @@ -12,7 +12,8 @@ ) from dbt.contracts.graph.compiled import CompiledResource from dbt.exceptions import raise_compiler_error, MacroReturn, raise_parsing_error -from dbt.logger import GLOBAL_LOGGER as logger +from dbt.events.functions import fire_event +from dbt.events.types import MacroEventInfo, MacroEventDebug from dbt.version import __version__ as dbt_version # These modules are added to the context. Consider alternative @@ -481,9 +482,9 @@ def log(msg: str, info: bool = False) -> str: {% endmacro %}" """ if info: - logger.info(msg) + fire_event(MacroEventInfo(msg)) else: - logger.debug(msg) + fire_event(MacroEventDebug(msg)) return '' @contextproperty diff --git a/core/dbt/context/providers.py b/core/dbt/context/providers.py index 9fd2d64a7a8..7d6b88e6961 100644 --- a/core/dbt/context/providers.py +++ b/core/dbt/context/providers.py @@ -51,7 +51,6 @@ raise_parsing_error, ) from dbt.config import IsFQNResource -from dbt.logger import GLOBAL_LOGGER as logger, SECRET_ENV_PREFIX # noqa from dbt.node_types import NodeType from dbt.utils import ( diff --git a/core/dbt/events/types.py b/core/dbt/events/types.py index 15e6003abde..892061417ad 100644 --- a/core/dbt/events/types.py +++ b/core/dbt/events/types.py @@ -105,6 +105,22 @@ def cli_msg(self) -> str: return f"Performance info: {self.path}" +@dataclass +class MacroEventInfo(InfoLevel, CliEventABC): + msg: str + + def cli_msg(self) -> str: + return self.msg + + +@dataclass +class MacroEventDebug(DebugLevel, CliEventABC): + msg: str + + def cli_msg(self) -> str: + return self.msg + + # since mypy doesn't run on every file we need to suggest to mypy that every # class gets instantiated. But we don't actually want to run this code. # making the conditional `if False` causes mypy to skip it as dead code so @@ -122,3 +138,5 @@ def cli_msg(self) -> str: ManifestChecked() ManifestFlatGraphBuilt() ReportPerformancePath(path='') + MacroEventInfo(msg='') + MacroEventDebug(msg='')