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

support "delay" and "encoding" for <logfile> #51

Merged
merged 2 commits into from Dec 4, 2018

Conversation

freddrake
Copy link
Contributor

- neither parameter is supported for STDOUT, STDERR
  (errors are reported at the time the handler is
  constructed)

- closes #49
Copy link
Member

@mgedmin mgedmin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@jamadden jamadden left a comment

Choose a reason for hiding this comment

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

LGTM with the exception of what looks like an error in Win32FileHandler

if self.delay:
self.stream = None
else:
self.stream = open(self.baseFilename, self.mode, self.encoding)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the call to open is correct here for either Python 2 or 3. On Python 2 the signature is open(name[, mode[, buffering]]). On Python 3 the signature is open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None). So both versions are going to interpret self.encoding as buffering.

To get an open that supports encoding= on Python 2, you can use io.open

I believe this code is not tested by Travis and is excluded from the coverage report

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right! Fixed in 63465a8.

logging.FileHandler._open already deals with py2/py3 compatiblity, and handles
all the parameters to open a file in a consistent way; no need to reimplement
in just one case
@freddrake freddrake merged commit 4de9bea into master Dec 4, 2018
@freddrake freddrake deleted the fd-logfile-delay-and-encoding branch December 4, 2018 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support delay parameter for file-based handlers
3 participants