-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
Found 20+ instances of debug print statements throughout the codebase:
if DEBUG_MODE:
print(f"DEBUG: Some debug info")Issues with print() for debugging
- No log levels - Can't filter by severity (INFO, WARNING, ERROR)
- No structured logging - Hard to parse/search logs
- Doesn't write to log files - Only goes to stdout
- No timestamps - Hard to correlate events
- No context - Missing module/function name
- Production risk - If DEBUG_MODE accidentally enabled, prints go to stdout
Affected Files
services/data_deletion.py- 4 instancesservices/event_service.py- 6 instancesservices/auth_service.py- 8+ instances- Many other files
Current State (Bad)
if DEBUG_MODE:
print(f"DEBUG: Received code: {auth_code[:20]}...")
print(f"DEBUG: Using WorkOS SSO for Google OAuth")Desired State (Good)
logger.debug(f"Received code: {auth_code[:20]}...")
logger.debug("Using WorkOS SSO for Google OAuth")Benefits of Proper Logging
✅ Log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
✅ Automatic timestamps
✅ Module/function context
✅ Can write to files, syslog, external services
✅ Structured logging support
✅ Better performance (logging framework handles filtering)
✅ Industry standard
Recommended Implementation
1. Create logging config
# utils/logging_config.py
import logging
from config import DEBUG_MODE
def setup_logging():
log_level = logging.DEBUG if DEBUG_MODE else logging.INFO
logging.basicConfig(
level=log_level,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(), # Console
logging.FileHandler('app.log') # File
]
)2. Use in each module
import logging
logger = logging.getLogger(__name__)
# Instead of:
if DEBUG_MODE:
print(f"DEBUG: Something happened")
# Do this:
logger.debug("Something happened")
logger.info("User logged in: %s", user_email)
logger.warning("Rate limit approaching: %d/%d", current, limit)
logger.error("Failed to delete user: %s", error)3. Structured logging (optional but recommended)
import structlog
logger = structlog.get_logger()
logger.info("user_login", user_email=email, ip=ip_address)Migration Strategy
- Phase 1: Add logging config to
app.py - Phase 2: Replace prints in critical paths (auth, API, data deletion)
- Phase 3: Replace remaining prints
- Phase 4: Remove
if DEBUG_MODEguards (logging framework handles this)
Quick Win
Replace all instances with a regex find/replace:
Find: if DEBUG_MODE:\s+print\(f?"DEBUG: (.+)"\)
Replace: logger.debug("\1")
Labels
technical-debt, logging, low-priority, good-first-issue
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request