Skip to content

Conversation

@jkebinger
Copy link
Collaborator

Summary

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 (TRACE, DEBUG, INFO, WARN, ERROR, FATAL)
  • get_log_level() method with context-based evaluation using reforge-sdk-logging context
  • logger_key option (default: "log-levels.default") for configuring the config key
  • LoggerFilter for standard Python logging integration
  • LoggerProcessor for structlog integration (optional dependency via extras)
  • Evaluates LOG_LEVEL_V2 config type with context: {"reforge-sdk-logging": {"lang": "python", "logger-path": logger_name}}
  • Returns DEBUG as default when config not found
  • No telemetry/record_log functionality (removed from predecessor)

Changes

Core Implementation

  • sdk_reforge/log_level.py - LogLevel enum with Python logging level mapping
  • sdk_reforge/logging.py - LoggerFilter and LoggerProcessor implementations
  • sdk_reforge/sdk.py - Added get_log_level() method
  • sdk_reforge/options.py - Added logger_key parameter
  • sdk_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() method
  • tests/test_logging.py - Tests for LoggerFilter and LoggerProcessor

Examples

  • examples/standard-logging/ - Complete example for standard Python logging
  • examples/structlog/ - Complete example for structlog integration

Usage

Standard Logging

import logging
from sdk_reforge import ReforgeSDK, Options, LoggerFilter

def configure_logger():
    handler.addFilter(LoggerFilter())

sdk = ReforgeSDK(Options(on_ready_callback=configure_logger))
logger = logging.getLogger("myapp")
logger.info("This message is controlled by Reforge config")

Structlog

import structlog
from sdk_reforge import ReforgeSDK, Options, LoggerProcessor

structlog.configure(
    processors=[
        structlog.stdlib.add_log_level,
        LoggerProcessor().processor,
        # ... other processors
    ]
)

sdk = ReforgeSDK(Options())
logger = structlog.getLogger()
logger.info("This message is controlled by Reforge config")

Testing

All tests passing:

  • 3 tests in test_log_level.py
  • 4 tests in test_logging.py
  • All pre-commit hooks passing (black, ruff, prettier, mypy)

jkebinger and others added 3 commits October 23, 2025 16:26
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>
Copy link
Contributor

@jdwyah jdwyah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

jkebinger and others added 3 commits November 4, 2025 11:30
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>
Copy link
Contributor

@jdwyah jdwyah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

@jkebinger jkebinger merged commit d8691b8 into main Nov 4, 2025
7 checks passed
@jkebinger jkebinger deleted the loglevel-v2 branch November 4, 2025 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants