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

Use rotating log files #437

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

lucyleeow
Copy link
Contributor

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

@codecov
Copy link

codecov bot commented Jul 9, 2020

Codecov Report

Merging #437 into master will decrease coverage by 0.00%.
The diff coverage is 95.65%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
ramp-engine/ramp_engine/dispatcher.py 94.66% <90.90%> (-0.54%) ⬇️
ramp-engine/ramp_engine/base.py 95.38% <100.00%> (+0.38%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 571a01a...0570fe2. Read the comment docs.

Copy link
Collaborator

@agramfort agramfort left a 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

streamHandler -> stream_handler

Copy link
Collaborator

@agramfort agramfort left a 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"
Copy link
Collaborator

@rth rth Oct 16, 2020

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.

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

Successfully merging this pull request may close these issues.

3 participants