Repository navigation
Write STDERR logs to stderr - #2701
Merged
Merged
Conversation
A log configured with `filename: STDERR` (the default for error_log) built its StreamHandler on sys.stdout, so it was indistinguishable from STDOUT. Fixes AppDaemon#2699
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2699.
A log configured with
filename: STDERRbuilt itsStreamHandleronsys.stdout, so it ended up on stdout. That includes the defaulterror_log, which the docs already say goes to stderr. This switches the handler tosys.stderr.Behaviour change worth calling out: with the default config,
error_logoutput now actually reaches stderr. Anyone redirecting only stdout (e.g.appdaemon > ad.log) will no longer see error-log lines in that file. That's what the docs describe, but it isn't what happened before.Tests:
tests/unit/test_logging_streams.pyconfigures one STDOUT and one STDERR log and checks each line lands on the right stream. It fails ondevand passes with the fix.To test
Loggingwithout touching the sharedAppDaemon/Errorloggers, I added amake_loggingfixture totests/unit/conftest.py. It builds a freshLoggingoutside the singleton with uniquely named loggers and detaches their handlers afterwards. Two other logging PRs I'm opening (JSON output, syslog level prefix) add the identical fixture, so they merge cleanly in any order.