Skip to content

Commit

Permalink
fix permission error when used locally
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronan committed Sep 19, 2024
1 parent 1376366 commit 26cfbe3
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions pyroengine/logger_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@

# Define the logging format
log_format = "%(asctime)s | %(levelname)s: %(message)s"
os.makedirs(os.path.dirname("/var/log/engine.log"), exist_ok=True)

if not os.path.exists("/var/log/engine.log"):
open("/var/log/engine.log", "a").close() # Create the file if it doesn't exist

os.chmod("/var/log/engine.log", 0o664)

# Create a StreamHandler (for stdout)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(logging.Formatter(log_format))

# Create a TimedRotatingFileHandler (for writing logs to a new file every day)
file_handler = TimedRotatingFileHandler("/var/log/engine.log", when="midnight", interval=1, backupCount=5)
file_handler = TimedRotatingFileHandler("engine.log", when="midnight", interval=1, backupCount=5)
file_handler.setFormatter(logging.Formatter(log_format))
file_handler.suffix = "%Y-%m-%d" # Adds a date suffix to the log file name

Expand Down

0 comments on commit 26cfbe3

Please sign in to comment.