Skip to content

Commit

Permalink
- fix bug if logfile is just a filename
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelRosier committed Jan 16, 2024
1 parent d94aab1 commit 0c8b34a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions brainles_aurora/inferer/inferer.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ def _setup_logger(self, log_file: str | Path | None = None) -> Logger:
if log_file:
# Create a file handler. We dont add it to the logger directly, but to the dual_stderr_output
# This way als console output includign excpetions will be redirceted to the log file

os.makedirs(os.path.dirname(log_file), exist_ok=True)
parent_dir = os.path.dirname(log_file)
# create parent dir if the path is more than just a file name
if parent_dir:
os.makedirs(parent_dir, exist_ok=True)
file_handler = logging.FileHandler(log_file)

self.dual_stderr_output.set_file_handler_stream(file_handler.stream)
Expand Down

0 comments on commit 0c8b34a

Please sign in to comment.