Skip to content

v4.5.0: Logging Infrastructure Desync Fixes & Lambda Response Type Safety

Choose a tag to compare

@Kydoimos97 Kydoimos97 released this 30 Sep 21:01
· 40 commits to release since this release
7a8fdbc

Major Infrastructure Changes

Logging System Refactor

  • Replaced ConfigManager with LoggerStateManager for centralized state and service management
  • Consolidated initialization logic and streamlined public API
  • Added update_global_handlers() for dynamic root/global handler synchronization
  • Enhanced LogOptions type safety with proper instance handling
  • Improved color/formatter consistency for DEBUG and INTERNAL log levels

Internal Logging Consistency

  • Standardized internal logging across all modules: replaced logger.debug with logger._internal_log
  • Affects: JsonParser, TypeChecker, Retryable, RdsServiceGateway, S3ServiceGateway, AwsClientHub, SSH components
  • Ensures consistent internal message handling and reduces noise in user-facing logs

Lambda Response Type Safety

Structured Response Handling

  • Renamed: build_lambda_responsehandle_lambda_response for clarity
  • Introduced LambdaResponse class with strict type validation
  • Added comprehensive status code validation (200-504 range)
  • Implemented standardized error messages for all supported HTTP codes
  • Enhanced serialization with RobustJSONEncoder integration

Type Safety Improvements

  • Enforces valid Lambda proxy response codes at compile time
  • Prevents malformed responses through structured validation
  • Provides debug-friendly truncated representations for large payloads

Enhanced Serialization Support

Robust JSON Handling

  • Extended robust_serializer support: Enum, Path, UUID, Pydantic models, dataclasses, sets, bytes
  • Added RobustJSONEncoder class for seamless json.dumps() integration
  • Introduced truncate_display() utility for safe logging of large objects
  • Better handling of complex nested structures

Code Quality Improvements

Test Infrastructure

  • Refactored test_optional_imports.py: standardized imports, improved error handling
  • Expanded test coverage for additional WrenchCL functionality
  • Better AWS dependency management error reporting

Import & Configuration

  • Fixed export typo in __init__.py: corrected string format consistency
  • Optimized environment variable handling for .env loading
  • Enhanced AWS dependency error messages with clearer package lists

Bug Fixes & Stability

Configuration Management

  • Fixed LoggerStateManager state application and restoration for context managers
  • Improved handler level synchronization during configuration changes
  • Enhanced environment detection and metadata handling

Performance & Threading

  • Better thread safety in configuration changes
  • Reduced redundant formatter updates
  • Streamlined service initialization flow

This refactor significantly improves the logging system's maintainability while adding robust type safety to Lambda responses and expanding serialization capabilities.