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

Fix --quiet CLI Parameter Regression #6858

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230203-162813.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Fix regression of --quiet cli parameter behavior
time: 2023-02-03T16:28:13.097276-05:00
custom:
Author: peterallenwebb
Issue: "6749"
12 changes: 9 additions & 3 deletions core/dbt/events/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
metadata_vars: Optional[Dict[str, str]] = None


# The "fallback" logger is used as a stop-gap so that console logging works before the logging
# configuration is fully loaded.
def setup_fallback_logger(use_legacy: bool, level: EventLevel) -> None:
cleanup_event_logger()
config = _get_logbook_log_config(level) if use_legacy else _get_stdout_config(level)
EVENT_MANAGER.add_logger(config)


def setup_event_logger(log_path: str, level_override: Optional[EventLevel] = None):
cleanup_event_logger()
make_log_dir_if_missing(log_path)
Expand Down Expand Up @@ -113,9 +121,7 @@ def cleanup_event_logger():
# currently fire before logs can be configured by setup_event_logger(), we
# create a default configuration with default settings and no file output.
EVENT_MANAGER: EventManager = EventManager()
EVENT_MANAGER.add_logger(
_get_logbook_log_config() if flags.ENABLE_LEGACY_LOGGER else _get_stdout_config()
)
setup_fallback_logger(bool(flags.ENABLE_LEGACY_LOGGER), EventLevel.INFO)


# This global, and the following two functions for capturing stdout logs are
Expand Down
11 changes: 10 additions & 1 deletion core/dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
from pathlib import Path

import dbt.version
from dbt.events.functions import fire_event, setup_event_logger, LOG_VERSION
from dbt.events.functions import fire_event, setup_event_logger, setup_fallback_logger, LOG_VERSION
from dbt.events.types import (
EventLevel,
MainEncounteredError,
MainKeyboardInterrupt,
MainReportVersion,
Expand Down Expand Up @@ -178,7 +179,15 @@ def handle_and_check(args):
# Set flags from args, user config, and env vars
user_config = read_user_config(flags.PROFILES_DIR) # This is read again later
flags.set_from_args(parsed, user_config)

# If the user has asked to supress non-error logging on the cli, we want to respect that as soon as possible,
# so that any non-error logging done before full log config is loaded and ready is filtered accordingly.
setup_fallback_logger(
bool(flags.ENABLE_LEGACY_LOGGER), EventLevel.ERROR if flags.QUIET else EventLevel.INFO
)

dbt.tracking.initialize_from_flags()

# Set log_format from flags
parsed.cls.set_log_format()

Expand Down