Skip to content

Commit

Permalink
Add log rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
GJFR committed Dec 4, 2024
1 parent a6657d5 commit d43d4a7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ nginx/ssl/keys/*
**/node_modules
**/junit.xml

# Screenshots
# Screenshots and logs
logs/*.log.*
logs/screenshots/*
!logs/screenshots/.gitkeep

Expand Down
5 changes: 2 additions & 3 deletions bci/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def configure_loggers():
bci_logger.addHandler(stream_handler)

# Configure file handler
file_handler = logging.handlers.RotatingFileHandler(f'/app/logs/{hostname}.log', mode='a', backupCount=2)
file_handler = logging.handlers.RotatingFileHandler(f'/app/logs/{hostname}.log', mode='a', backupCount=3, maxBytes=8*1024*1024)
file_handler.setLevel(logging.DEBUG)
file_handler.setFormatter(Loggers.formatter)
bci_logger.addHandler(file_handler)
Expand All @@ -154,8 +154,7 @@ def configure_loggers():

# Configure memory handler
Loggers.memory_handler.setLevel(logging.INFO)
buffer_formatter = logging.handlers.BufferingHandler(Loggers.formatter)
Loggers.memory_handler.setFormatter(buffer_formatter)
Loggers.memory_handler.setFormatter(Loggers.formatter)
bci_logger.addHandler(Loggers.memory_handler)

# Log uncaught exceptions
Expand Down

0 comments on commit d43d4a7

Please sign in to comment.