Skip to content

Commit

Permalink
fix(file_logger): do not create dirs if they exist but the file doesn't
Browse files Browse the repository at this point in the history
  • Loading branch information
serhez committed Mar 7, 2024
1 parent c078467 commit 8b1a6f0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mloggers/file_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def __init__(self, file_path: str):
# Create the file if it does not exist
if not os.path.exists(file_path):
dir_path = os.path.dirname(file_path)
os.makedirs(dir_path)
try:
os.makedirs(dir_path)
except FileExistsError:
pass
with open(file_path, "w") as file:
file.write("")

Expand Down

0 comments on commit 8b1a6f0

Please sign in to comment.