Skip to content

Commit

Permalink
Only try to create log directory if file logging is enabled
Browse files Browse the repository at this point in the history
There's no need to create the log directory if we won't be logging to a
file in it.
  • Loading branch information
ericfreese committed Oct 30, 2024
1 parent dd77210 commit 968689f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20241030-130239.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Don't try to create the log directory when file logging is disabled
time: 2024-10-30T13:02:39.206813142-06:00
custom:
Author: ericfreese
Issue: "10948"
3 changes: 2 additions & 1 deletion core/dbt/events/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def _logfile_filter(log_cache_events: bool, line_format: LineFormat, msg: EventM

def setup_event_logger(flags, callbacks: List[Callable[[EventMsg], None]] = []) -> None:
cleanup_event_logger()
make_log_dir_if_missing(flags.LOG_PATH)
event_manager = get_event_manager()
event_manager.callbacks = callbacks.copy()
add_callback_to_manager(track_behavior_change_warn)
Expand All @@ -93,6 +92,8 @@ def setup_event_logger(flags, callbacks: List[Callable[[EventMsg], None]] = [])
add_logger_to_manager(console_config)

if flags.LOG_LEVEL_FILE != "none":
make_log_dir_if_missing(flags.LOG_PATH)

# create and add the file logger to the event manager
log_file = os.path.join(flags.LOG_PATH, "dbt.log")
log_file_format = _line_format_from_str(flags.LOG_FORMAT_FILE, LineFormat.DebugText)
Expand Down

0 comments on commit 968689f

Please sign in to comment.