todoappapi / core /CLAUDE.md
GrowWithTalha's picture
feat: sync backend changes from main repo
dc3879e
<claude-mem-context>
# Recent Activity
<!-- This section is auto-generated by claude-mem. Edit content outside the tags. -->
### Jan 18, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #18 | 2:22 PM | 🟣 | Completed US6 persistence implementation with integration tests | ~483 |
| #17 | 2:21 PM | ✅ | Created PR for AI chatbot feature with US6 persistence implementation | ~477 |
| #16 | 2:13 PM | ✅ | Pushed AI chatbot branch updates to remote repository | ~307 |
| #15 | 2:12 PM | 🟣 | Completed US6 persistence implementation with integration tests and database fixes | ~395 |
| #14 | 2:11 PM | 🟣 | Completed US6 persistence implementation with test infrastructure fixes | ~388 |
| #12 | 2:05 PM | 🔄 | Refactored database connection to support SQLite and PostgreSQL with conditional configuration | ~329 |
### Jan 30, 2026
| ID | Time | T | Title | Read |
|----|------|---|-------|------|
| #913 | 11:12 AM | 🔵 | Backend logging configuration uses structured JSON format with detailed metadata | ~273 |
</claude-mem-context>
## Phase IV: Structured Logging
### logging.py
**Purpose**: Structured JSON logging for cloud-native deployment
**Functions**:
- `setup_logging(level: str)` - Configure JSON logging with stdout handler
- `get_logger(name: str)` - Get logger instance with JSON formatter
- `with_correlation_id(correlation_id: str)` - Add correlation ID to log context
- `clear_correlation_id()` - Clear correlation ID context
**Usage**:
```python
from core.logging import get_logger, with_correlation_id
logger = get_logger(__name__)
logger.info("Processing request", extra={"extra_fields": with_correlation_id("req-123")})
```
**Log Format**:
```json
{
"timestamp": "2025-01-27T10:00:00Z",
"level": "INFO",
"logger": "backend.api.tasks",
"message": "Task created successfully",
"module": "tasks",
"function": "create_task",
"line": 42,
"correlation_id": "req-123"
}
```