Skip to content

Commit

Permalink
Set the log file permissions *before* shutting down
Browse files Browse the repository at this point in the history
The previous logic was not particularly useful...
  • Loading branch information
JamesWrigley committed Oct 24, 2024
1 parent be6ed9d commit c45518b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions damnit/backend/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ def listen():
file_handler.setFormatter(formatter)
logging.root.addHandler(file_handler)

# Ensure that the log file is writable by everyone (so that different users
# can start the backend).
if os.stat("amore.log").st_uid == os.getuid():
os.chmod("amore.log", 0o666)

Check warning on line 153 in damnit/backend/listener.py

View check run for this annotation

Codecov / codecov/patch

damnit/backend/listener.py#L152-L153

Added lines #L152 - L153 were not covered by tests

log.info(f"Running on {platform.node()} under user {getpass.getuser()}, PID {os.getpid()}")
try:
with EventProcessor() as processor:
Expand All @@ -159,11 +164,5 @@ def listen():
# Flush all logs
logging.shutdown()

# Ensure that the log file is writable by everyone (so that different users
# can start the backend).
if os.stat("amore.log").st_uid == os.getuid():
os.chmod("amore.log", 0o666)


if __name__ == '__main__':
listen()

0 comments on commit c45518b

Please sign in to comment.