diff --git a/core/dbt/task/compile.py b/core/dbt/task/compile.py index 4541dfd1567..e016dbeb4b9 100644 --- a/core/dbt/task/compile.py +++ b/core/dbt/task/compile.py @@ -1,5 +1,6 @@ import threading +from dbt.flags import get_flags from dbt.artifacts.schemas.run import RunStatus, RunResult from dbt_common.events.base_types import EventLevel from dbt_common.events.functions import fire_event @@ -89,16 +90,22 @@ def task_end_messages(self, results): matched_results = [] for result in matched_results: - fire_event( - CompiledNode( - node_name=result.node.name, - compiled=result.node.compiled_code, - is_inline=is_inline, - output_format=output_format, - unique_id=result.node.unique_id, - ) + + compiled_node_event = CompiledNode( + node_name=result.node.name, + compiled=result.node.compiled_code, + is_inline=is_inline, + output_format=output_format, + unique_id=result.node.unique_id, + quiet=get_flags().QUIET, ) + if get_flags().LOG_FORMAT == "json": + fire_event(compiled_node_event) + else: + # Cleaner to leave as print than to mutate the logger not to print timestamps. + print(compiled_node_event.message()) + def _runtime_initialize(self): if getattr(self.args, "inline", None): try: diff --git a/core/dbt/task/show.py b/core/dbt/task/show.py index 608ba6fdebd..ae1e38bd3a3 100644 --- a/core/dbt/task/show.py +++ b/core/dbt/task/show.py @@ -2,6 +2,7 @@ import threading import time +from dbt.flags import get_flags from dbt.context.providers import generate_runtime_model_context from dbt.contracts.graph.nodes import SeedNode from dbt.artifacts.schemas.run import RunResult, RunStatus @@ -98,16 +99,21 @@ def task_end_messages(self, results): if hasattr(result.node, "version") and result.node.version: node_name += f".v{result.node.version}" - fire_event( - ShowNode( - node_name=node_name, - preview=output.getvalue(), - is_inline=is_inline, - output_format=self.args.output, - unique_id=result.node.unique_id, - ) + show_node_event = ShowNode( + node_name=node_name, + preview=output.getvalue(), + is_inline=is_inline, + output_format=self.args.output, + unique_id=result.node.unique_id, + quiet=get_flags().QUIET, ) + if get_flags().LOG_FORMAT == "json": + fire_event(show_node_event) + else: + # Cleaner to leave as print than to mutate the logger not to print timestamps. + print(show_node_event.message()) + def _handle_result(self, result): super()._handle_result(result)