Repository navigation
refactor: use module-scoped loggers instead of the root logger - #195
Merged
Merged
Conversation
Replace bare logging.* calls in the library with a per-module `_logger = logging.getLogger(__name__)` so records are emitted under the `acp.*` namespace and can be configured or silenced by applications. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Library modules previously called
logging.exception(...),logging.debug(...), etc. directly, which emits records on the root logger. This makes it impossible for applications to tune or silence ACP's logging without affecting everything else.Each module now defines
_logger = logging.getLogger(__name__)and logs through it, so records are emitted under theacp.*namespace (e.g.acp.connection,acp.task.supervisor,acp.ws.server) and can be configured vialogging.getLogger("acp").Touched modules:
src/acp/connection.pysrc/acp/stdio.pysrc/acp/task/supervisor.pysrc/acp/ws/server.pyExamples (
examples/agent.py,examples/client.py) are left unchanged since they are standalone scripts that configure root logging themselves.No behavioral change other than the logger name on emitted records; messages and levels are unchanged.
Testing
make check: ruff, format, types, deptry all passuv run python -m pytest: 540 passed, 1 skipped (the existingcaplog-based tests intests/test_request_error_logging.pystill pass sincecaplogcaptures propagated records)🤖 Generated with Claude Code