fix: silence default stderr logging via NullHandler (closes #36) - #79
Open
Nexory wants to merge 1 commit into
Open
fix: silence default stderr logging via NullHandler (closes #36)#79Nexory wants to merge 1 commit into
Nexory wants to merge 1 commit into
Conversation
Closes Polymarket#36 Adds a NullHandler to the package's top-level logger so the library does not emit log records via Python's lastResort handler when the consuming application has not configured logging. This matches the standard library-logging pattern recommended in the Python docs (https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library). Users who want to see internal SDK logs can opt in: logging.getLogger("py_clob_client_v2").setLevel(logging.INFO) logging.getLogger("py_clob_client_v2").addHandler(handler) Without this change, modules that log at ERROR (e.g. http_helpers.helpers) print to stderr by default, which breaks curses-based terminal UIs and prevents callers from handling errors entirely on their own.
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.
Summary
Adds a
NullHandlerto the package's top-level logger sopy_clob_client_v2does not emit log records via Python'slastResorthandler when the consuming application has not configured logging.This is the standard library-logging pattern recommended in the Python logging cookbook:
Without this change, modules that log at
ERROR(e.g.http_helpers/helpers.py:73and:89, both prefixed[py_clob_client_v2]) print tostderrby default, which breaks curses-based terminal UIs and prevents callers from handling errors fully on their own.Closes #36.
Change
Added at the top of
py_clob_client_v2/__init__.pybefore the public imports. The underscore on the import preventsfrom py_clob_client_v2 import *from re-exportinglogging.Behaviour
lastResortlogging.basicConfig(...)configuredlogging.getLogger("py_clob_client_v2").setLevel(...)Test plan
py_clob_client_v2in a fresh interpreter with no logging config; confirm no warning is printed.Happy to add a regression test in
tests/if maintainers prefer.