Description
The codebase contains 60+ print() statements used for debugging output. These should be replaced with Python's logging module for better control, filtering, and production readiness.
Locations
generator.py
- Lines 17, 53, 77: Print statements in
__init__
- Lines 98-145: Conditional debug output throughout execution
- Lines 295-341: CRASH_DEBUG comments with print statements
api.py
- Multiple print statements for request logging
Current Code Example
# generator.py lines 98-145
print(f"DEBUG: model_id={model_id}")
print(f"DEBUG: extraction_result={extraction_result}")
# ... many more
Proposed Solution
1. Configure logging at module level
# generator.py
import logging
logger = logging.getLogger(__name__)
# In functions:
logger.debug("model_id=%s", model_id)
logger.info("AIBOM generation completed for %s", model_id)
logger.error("Failed to extract metadata: %s", error)
2. Use lazy string formatting
# Bad (string always constructed):
print(f"DEBUG: value={expensive_computation()}")
# Good (only constructed if DEBUG enabled):
logger.debug("value=%s", expensive_computation)
3. Add log levels appropriately
| Level |
Use Case |
| DEBUG |
Detailed extraction steps, field values |
| INFO |
AIBOM generation success, API requests |
| WARNING |
Missing optional fields, fallback used |
| ERROR |
Extraction failures, API errors |
Benefits
- Controllable verbosity via log levels
- Log rotation and persistence
- Structured output for log aggregation
- Quieter unit test output
- Production-ready logging
Additional Cleanup
Remove CRASH_DEBUG comments and conditional print blocks (lines 295-341) that indicate iterative debugging rather than clean code.
Description
The codebase contains 60+
print()statements used for debugging output. These should be replaced with Python'sloggingmodule for better control, filtering, and production readiness.Locations
generator.py
__init__api.py
Current Code Example
Proposed Solution
1. Configure logging at module level
2. Use lazy string formatting
3. Add log levels appropriately
Benefits
Additional Cleanup
Remove CRASH_DEBUG comments and conditional print blocks (lines 295-341) that indicate iterative debugging rather than clean code.