Skip to content

Commit b295bf5

Browse files
authored
Merge branch 'main' into 7785_fail_fast
2 parents 86b030c + a8e3afe commit b295bf5

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Fix accidental propagation of log messages to root logger.
3+
time: 2023-06-15T10:26:39.139421-04:00
4+
custom:
5+
Author: peterallenwebb
6+
Issue: "7872"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
kind: Fixes
2+
body: Fixed an issue which blocked debug logging to stdout with --log-level debug,
3+
unless --debug was also used.
4+
time: 2023-06-15T11:05:38.053387-04:00
5+
custom:
6+
Author: peterallenwebb
7+
Issue: "7872"

core/dbt/events/eventmgr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def _get_python_log_for_handler(self, handler: logging.Handler):
110110
log.setLevel(_log_level_map[self.level])
111111
handler.setFormatter(logging.Formatter(fmt="%(message)s"))
112112
log.handlers.clear()
113+
log.propagate = False
113114
log.addHandler(handler)
114115
return log
115116

core/dbt/events/functions.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ def setup_event_logger(flags, callbacks: List[Callable[[EventMsg], None]] = [])
3939
else:
4040
if flags.LOG_LEVEL != "none":
4141
line_format = _line_format_from_str(flags.LOG_FORMAT, LineFormat.PlainText)
42-
log_level = EventLevel.DEBUG if flags.DEBUG else EventLevel(flags.LOG_LEVEL)
42+
log_level = (
43+
EventLevel.ERROR
44+
if flags.QUIET
45+
else EventLevel.DEBUG
46+
if flags.DEBUG
47+
else EventLevel(flags.LOG_LEVEL)
48+
)
4349
console_config = _get_stdout_config(
4450
line_format,
45-
flags.DEBUG,
4651
flags.USE_COLORS,
4752
log_level,
4853
flags.LOG_CACHE_EVENTS,
49-
flags.QUIET,
5054
)
5155
EVENT_MANAGER.add_logger(console_config)
5256

@@ -81,11 +85,9 @@ def _line_format_from_str(format_str: str, default: LineFormat) -> LineFormat:
8185

8286
def _get_stdout_config(
8387
line_format: LineFormat,
84-
debug: bool,
8588
use_colors: bool,
8689
level: EventLevel,
8790
log_cache_events: bool,
88-
quiet: bool,
8991
) -> LoggerConfig:
9092

9193
return LoggerConfig(
@@ -97,8 +99,6 @@ def _get_stdout_config(
9799
filter=partial(
98100
_stdout_filter,
99101
log_cache_events,
100-
debug,
101-
quiet,
102102
line_format,
103103
),
104104
output_stream=sys.stdout,
@@ -107,16 +107,11 @@ def _get_stdout_config(
107107

108108
def _stdout_filter(
109109
log_cache_events: bool,
110-
debug_mode: bool,
111-
quiet_mode: bool,
112110
line_format: LineFormat,
113111
msg: EventMsg,
114112
) -> bool:
115-
return (
116-
(msg.info.name not in ["CacheAction", "CacheDumpGraph"] or log_cache_events)
117-
and (EventLevel(msg.info.level) != EventLevel.DEBUG or debug_mode)
118-
and (EventLevel(msg.info.level) == EventLevel.ERROR or not quiet_mode)
119-
and not (line_format == LineFormat.Json and type(msg.data) == Formatting)
113+
return (msg.info.name not in ["CacheAction", "CacheDumpGraph"] or log_cache_events) and not (
114+
line_format == LineFormat.Json and type(msg.data) == Formatting
120115
)
121116

122117

@@ -147,11 +142,9 @@ def _get_logbook_log_config(
147142
) -> LoggerConfig:
148143
config = _get_stdout_config(
149144
LineFormat.PlainText,
150-
debug,
151145
use_colors,
152-
EventLevel.DEBUG if debug else EventLevel.INFO,
146+
EventLevel.ERROR if quiet else EventLevel.DEBUG if debug else EventLevel.INFO,
153147
log_cache_events,
154-
quiet,
155148
)
156149
config.name = "logbook_log"
157150
config.filter = (
@@ -183,7 +176,7 @@ def cleanup_event_logger():
183176
EVENT_MANAGER.add_logger(
184177
_get_logbook_log_config(False, True, False, False) # type: ignore
185178
if ENABLE_LEGACY_LOGGER
186-
else _get_stdout_config(LineFormat.PlainText, False, True, EventLevel.INFO, False, False)
179+
else _get_stdout_config(LineFormat.PlainText, True, EventLevel.INFO, False)
187180
)
188181

189182
# This global, and the following two functions for capturing stdout logs are

0 commit comments

Comments
 (0)