Implement Centralized Logging System for strategicwm
Problem Description
Currently, the strategicwm library uses a mix of print statements and optional logging.Logger objects passed as arguments to functions (e.g., in client_lib.py). This ad-hoc approach leads to several issues:
- Inconsistent Output: Difficult to control verbosity levels globally across the library
- Integration Challenges: Harder for consumers of the library to capture or redirect logs programmatically
- Debugging Difficulty: Lack of standardized timestamps and log levels makes tracing execution flows more challenging
- Maintenance Burden: Mixed logging approaches create technical debt and reduce code quality
Proposed Solution
Implement a centralized logging configuration for the library with the following components:
1. Global Logger Configuration
Create a module-level logger setup (e.g., strategicwm.get_logger()) that ensures consistent formatting and handling across all modules.
2. Replace Print Statements
Systematically replace print(..., flush=True) calls with appropriate logging methods:
logger.debug() for detailed diagnostic information
logger.info() for general informational messages
logger.warning() for warning messages
logger.error() for error conditions
3. User Configurability
Allow users to easily configure logging levels (DEBUG, INFO, WARNING, ERROR) without modifying library code, following Python's standard logging best practices.
Implementation Details
Step 1: Create Logging Utility
Define a logging utility module at _src/utils/logging.py (or similar location) with:
import logging
from typing import Optional
def get_logger(name: str, level: Optional[int] = None) -> logging.Logger:
"""Get or create a logger with standardized configuration."""
logger = logging.getLogger(name)
if level is not None:
logger.setLevel(level)
return logger
def configure_logging(level: int = logging.INFO, format_string: Optional[str] = None):
"""Configure library-wide logging settings."""
# Implementation here
pass
Step 2: Update Existing Modules
- Update
client_lib.py and other modules to use the centralized logging utility
- Replace all
print statements used for logging purposes with appropriate logger calls
- Audit codebase for any remaining ad-hoc logging patterns
Step 3: Backward Compatibility
- Ensure backward compatibility where possible
- If the
logger argument in functions needs to be deprecated, clearly document breaking changes
- Provide migration guide for users currently passing logger objects
Step 4: Documentation
- Add logging configuration documentation to README or docs
- Provide examples of how users can configure logging for their use cases
- Document any breaking changes in CHANGELOG
Acceptance Criteria
Additional Context
This enhancement will significantly improve the library's maintainability and make it easier for users to integrate strategicwm into production environments where proper logging is essential.
Related Files
client_lib.py
- Any other modules currently using
print statements for logging
Labels: enhancement, good-first-issue, logging, code-quality
Difficulty: Medium
Estimated Effort: 4-8 hours
Implement Centralized Logging System for strategicwm
Problem Description
Currently, the
strategicwmlibrary uses a mix ofprintstatements and optionallogging.Loggerobjects passed as arguments to functions (e.g., inclient_lib.py). This ad-hoc approach leads to several issues:Proposed Solution
Implement a centralized logging configuration for the library with the following components:
1. Global Logger Configuration
Create a module-level logger setup (e.g.,
strategicwm.get_logger()) that ensures consistent formatting and handling across all modules.2. Replace Print Statements
Systematically replace
print(..., flush=True)calls with appropriate logging methods:logger.debug()for detailed diagnostic informationlogger.info()for general informational messageslogger.warning()for warning messageslogger.error()for error conditions3. User Configurability
Allow users to easily configure logging levels (
DEBUG,INFO,WARNING,ERROR) without modifying library code, following Python's standard logging best practices.Implementation Details
Step 1: Create Logging Utility
Define a logging utility module at
_src/utils/logging.py(or similar location) with:Step 2: Update Existing Modules
client_lib.pyand other modules to use the centralized logging utilityprintstatements used for logging purposes with appropriate logger callsStep 3: Backward Compatibility
loggerargument in functions needs to be deprecated, clearly document breaking changesStep 4: Documentation
Acceptance Criteria
printstatements used for logging purposes are replaced with logging calls_src/utils/logging.pyAdditional Context
This enhancement will significantly improve the library's maintainability and make it easier for users to integrate
strategicwminto production environments where proper logging is essential.Related Files
client_lib.pyprintstatements for loggingLabels:
enhancement,good-first-issue,logging,code-qualityDifficulty: Medium
Estimated Effort: 4-8 hours