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 9ab8af1
Showing 1 changed file with 2 additions and 1 deletion.
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 9ab8af1

Please sign in to comment.