Skip to content

Commit

Permalink
Fix for case where log files do not already exist
Browse files Browse the repository at this point in the history
  • Loading branch information
rhfogh committed Sep 24, 2023
1 parent 9cc9e9e commit ef1f741
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mxcube3/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,10 @@ def init_logging(log_file, log_level, enabled_logger_list):
log_formatter = ColorFormatter(fmt)

if log_file:
if not os.path.isfile(log_file):
fpt = open(log_file, "w")
fpt.write(" ")
fpt.close()
os.chmod(log_file, 0o666)
Path(log_file).touch()

Expand All @@ -370,6 +374,10 @@ def init_logging(log_file, log_level, enabled_logger_list):
log_file_handler.setFormatter(log_formatter)

uilog_file = f"{log_file[:-4]}_ui.log"
if not os.path.isfile(uilog_file):
fpt = open(uilog_file, "w")
fpt.write(" ")
fpt.close()
os.chmod(uilog_file, 0o666)
Path(uilog_file).touch()

Expand Down

0 comments on commit ef1f741

Please sign in to comment.