-
Notifications
You must be signed in to change notification settings - Fork 18
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
Use rotating log files #437
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #437 +/- ##
==========================================
- Coverage 93.13% 93.13% -0.01%
==========================================
Files 99 99
Lines 7970 7979 +9
==========================================
+ Hits 7423 7431 +8
- Misses 547 548 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
besides my pep8 nitpicks LGTM
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') # noqa | ||
fileHandler = logging.FileHandler(log_file, mode='a') | ||
fileHandler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fileHandler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) | |
file_handler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) |
formatter = logging.Formatter('%(asctime)s %(name)s %(levelname)s %(message)s') # noqa | ||
fileHandler = logging.FileHandler(log_file, mode='a') | ||
fileHandler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) | ||
fileHandler.setFormatter(formatter) | ||
streamHandler = logging.StreamHandler() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streamHandler = logging.StreamHandler() | |
stream_handler = logging.StreamHandler() |
fileHandler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) | ||
fileHandler.setFormatter(formatter) | ||
file_handler = RotatingFileHandler(log_file, maxBytes=1000, backupCount=2) | ||
file_handler.setFormatter(formatter) | ||
streamHandler = logging.StreamHandler() | ||
streamHandler.setFormatter(formatter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streamHandler -> stream_handler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glemaitre green button is all yours
from abc import ABCMeta, abstractmethod | ||
|
||
log_dir = "logs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we make this configurable somehow?
The issue is that this log folder will depend on the location from which we run a script as far as I understand (and also happens at import). It might be better to have a function that is called as necessary that takes as input a config object and returns this logger. Not sure how easy that would be though.
Reference Issue
Use a
RotatingFileHandler
to write to new log file once size limit met, as suggested by @glemaitre in #435.What does this implement/fix? Explain your changes.
Any other comments?
cc @maikia @agramfort