Add dynamic log level control with LoggerFilter and LoggerProcessor#15
Merged
Add dynamic log level control with LoggerFilter and LoggerProcessor#15
Conversation
Implements configurable log level management through Reforge configuration, allowing real-time control of logging verbosity without application restarts. Key features: - LogLevel enum mapping to Python logging levels - get_log_level() method with context-based evaluation - logger_key option (default: "log-levels.default") - LoggerFilter for standard Python logging integration - LoggerProcessor for structlog integration (optional dependency) - Evaluates LOG_LEVEL_V2 config type with reforge-sdk-logging context - Returns DEBUG as default when config not found - No telemetry/record_log functionality Includes comprehensive tests and examples for both standard logging and structlog integrations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Adds 'from __future__ import annotations' to test_logging.py to enable subscriptable types like logging.StreamHandler[Any] in Python 3.9. Fixes: TypeError: 'type' object is not subscriptable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Makes structlog available in the test environment so LoggerProcessor tests can run without being skipped. Structlog remains optional for end users via the extras mechanism. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <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
Implements configurable log level management through Reforge configuration, allowing real-time control of logging verbosity without application restarts.
Key Features
reforge-sdk-loggingcontext"log-levels.default") for configuring the config keyLOG_LEVEL_V2config type with context:{"reforge-sdk-logging": {"lang": "python", "logger-path": logger_name}}DEBUGas default when config not foundChanges
Core Implementation
sdk_reforge/log_level.py- LogLevel enum with Python logging level mappingsdk_reforge/logging.py- LoggerFilter and LoggerProcessor implementationssdk_reforge/sdk.py- Addedget_log_level()methodsdk_reforge/options.py- Addedlogger_keyparametersdk_reforge/__init__.py- Export logging classes (removed protobuf LogLevel to avoid conflicts)Dependencies
pyproject.toml- Made structlog optional via extras:pip install sdk-reforge[structlog]Tests
tests/test_log_level.py- Tests for LogLevel enum and get_log_level() methodtests/test_logging.py- Tests for LoggerFilter and LoggerProcessorExamples
examples/standard-logging/- Complete example for standard Python loggingexamples/structlog/- Complete example for structlog integrationUsage
Standard Logging
Structlog
Testing
All tests passing:
test_log_level.pytest_logging.py