Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update logger so that SherpaSAMP.log doesn't get too large #6

Open
jbudynk opened this issue May 6, 2015 · 1 comment
Open

Update logger so that SherpaSAMP.log doesn't get too large #6

jbudynk opened this issue May 6, 2015 · 1 comment

Comments

@jbudynk
Copy link
Member

jbudynk commented May 6, 2015

No description provided.

@jbudynk
Copy link
Member Author

jbudynk commented May 6, 2015

Take a look at the Python class logging.handlers.RotatingFileHandler.

handler = logging.handlers.RotatingFileHandler(
          LOG_FILENAME, maxBytes=20, backupCount=5)

This should let us specify the max file size for SherpaSAMP.log. Older log messages will be cut off when the size exceeds maxBytes, and added to a number of backup files backupCount. From https://docs.python.org/2/library/logging.handlers.html:

You can use the maxBytes and backupCount values to allow the file to rollover at a predetermined size. When the size is about to be exceeded, the file is closed and a new file is silently opened for output. Rollover occurs whenever the current log file is nearly maxBytes in length; if either of maxBytes or backupCount is zero, rollover never occurs. If backupCount is non-zero, the system will save old log files by appending the extensions ‘.1’, ‘.2’ etc., to the filename. For example, with a backupCount of 5 and a base file name of app.log, you would get app.log, app.log.1, app.log.2, up to app.log.5. The file being written to is always app.log. When this file is filled, it is closed and renamed to app.log.1, and if files app.log.1, app.log.2, etc. exist, then they are renamed to app.log.2, app.log.3 etc. respectively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant