Scope logToFile and logToConsole handlers to ib_async logger#218
Open
mahimn01 wants to merge 1 commit into
Open
Scope logToFile and logToConsole handlers to ib_async logger#218mahimn01 wants to merge 1 commit into
mahimn01 wants to merge 1 commit into
Conversation
Both helpers were attaching their handlers to the root logger via
`logging.getLogger()`, so calling them captured every log record in the
process, not just records from ib_async.
Attach handlers to `logging.getLogger("ib_async")` instead, and tighten
the duplicate-detection check in `logToConsole` to inspect the ib_async
namespace's own handlers plus root's (since records propagate up).
The v0.9.67 fix referenced in `docs/changelog.rst:437` addressed the
level-pollution side of this but left the handler attachment on root.
Fixes ib-api-reloaded#24
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 #24.
Both
logToFileandlogToConsolewere attaching their handlers to the root logger vialogging.getLogger(), so calling them captured every log record in the process, not just records from ib_async.Attaches handlers to
logging.getLogger("ib_async")instead, and tightens the duplicate-detection check inlogToConsoleto inspect the ib_async namespace's own handlers plus root's (since records propagate up).All internal modules already log under the
ib_async.*namespace (decoder,wrapper,ib,client,ibcontroller,flexreport) and none disable propagation, so user setups that catch records on the root logger keep working.The v0.9.67 fix referenced in
docs/changelog.rst:437(ib_insync #361) addressed the level-pollution side of this but left the handler attachment on root.Includes
tests/test_log_scoping.pycovering: logToFile scope + third-party isolation, logToConsole scope, duplicate-handler detection on repeat call, and cross-namespace duplicate detection when root already has a stderr handler.