Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix logcapture plugin to capture output from non-propagating loggers,… #948

Merged

Conversation

adamchainz
Copy link
Contributor

… and to not output 'no handlers could be found' message.

Found this when activating log capturing on my project's test suite, we would end up with a single message in the test output such as No handlers could be found for logger "foo.yes" for a logger that has propagate = False. This is because the logcapture plugin would clear the handlers and not replace them.

logging emits this message once per program: https://hg.python.org/cpython/file/2.7/Lib/logging/__init__.py#l1339

To fix this, I install the memory handler for every non-propagating logger (have to take care to find only legitimate loggers with propagate = False and not e.g. Placeholder objects). This not only stops the message from appearing but also captures their output which may help further with debugging.

… and to not output 'no handlers could be found' message
@jszakmeister
Copy link
Contributor

Seems reasonable. Thank you.

jszakmeister added a commit that referenced this pull request Nov 28, 2015
Fix logcapture plugin to capture output from non-propagating loggers,…
@jszakmeister jszakmeister merged commit bee3081 into nose-devs:master Nov 28, 2015
@adamchainz
Copy link
Contributor Author

🌈 🐰 🌈

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

Successfully merging this pull request may close these issues.

2 participants