←
TRCKR-218
Created: 2025-12-09
•
Updated: 2025-12-16
Relationships
Loading...
Attachments
Loading...
Comments (2)
agent
·
2025-12-09
Deployed to trckr.roboalch.com successfully.
Server restarted and is running with new logging code. The logging system is working correctly with default INFO level.
To enable DEBUG level logging for more detailed output, set LOG_LEVEL=DEBUG in the environment:
- For Docker: Add `LOG_LEVEL=DEBUG` to docker-compose.yml environment section
- For local dev: `export LOG_LEVEL=DEBUG` before running server
Current deployment status: ✓ Running on https://trckr.roboalch.com
agent
·
2025-12-09
Added comprehensive CRUDL and sync logging to both server and client:
## Changes Made
### Server-side Logging (server/)
1. **Created logging_config.py** (`/Users/joe/gitea/trckr/server/logging_config.py`)
- Centralized logging configuration
- Supports LOG_LEVEL environment variable
- Format: timestamp, level, module name, message
- Auto-configures uvicorn loggers
2. **Updated main.py** (lines 15, 32, 40-44, 47)
- Initialize logging on startup
- Log server version, database path
- Log shutdown events
3. **Updated auth.py** (lines 9, 11, 26-27, 34, 40, 55, 62, 64)
- Log authentication failures (WARN level)
- Log successful auth (DEBUG level)
- Log WebSocket auth attempts
4. **Updated websocket.py** (lines 12, 14, 34, 40, 46, 49-50, 55, 62, 70, 122, 138, 150, 154, 157)
- Log WebSocket connections/disconnections with client counts
- Log message types sent/received
- Log broadcast events to N clients
- Log connection errors with exception details
5. **Updated routes/issues.py** (lines 11, 21, 79, 125, 149, 165, 179, 193-194, 199, 211, 217, 250, 265, 271, 279)
- Log all CRUDL operations: create, read, update, delete, list
- Include entity IDs and operation details
- Log 404 errors with entity IDs
- Track fields being updated
6. **Updated routes/sync.py** (lines 11, 23, 115-119, 127-140, 161-164)
- Log sync start with client_id, last_sync_version, change count
- Log each change being processed (DEBUG)
- Log conflicts with resolution details (WARN)
- Log sync completion with statistics (applied, conflicts, server_changes, server_version)
### Client-side Logging (client/)
**Updated client/sync.py** (lines 14, 25, 158, 174, 187, 191, 197, 208, 283, 306, 334-335, 337, 346, 372-397, 429-453, 462-476, 490-493, 1148, 1154, 1157)
- Log sync configuration changes
- Log sync start/completion with statistics
- Log pending changes count
- Log HTTP requests and responses
- Log authentication errors
- Log conflicts with version details
- Log server change application
- Log retry attempts with backoff delays
- Log local change logging
## Implementation Notes
- Uses Python's standard logging module throughout
- Log levels follow best practices:
- DEBUG: Routine operations, detailed flow
- INFO: Significant operations (CRUDL, sync events)
- WARN: Issues that don't prevent operation (conflicts, failed auth)
- ERROR: Failures that prevent operation
- Avoids logging sensitive data (API keys are not logged in full)
- Configurable via LOG_LEVEL environment variable
- Format: "2025-12-09 16:32:11 [INFO] module.name - message"
## Testing
- All tests pass: 1069 passed, 38 skipped, 7 pre-existing failures
- Coverage: 77% overall
- Logging does not impact functionality
- Installed and verified working
## Example Log Output
Server startup:
```
2025-12-09 16:32:11 [INFO] server.main - Starting trckr server v0.1.0
2025-12-09 16:32:11 [INFO] server.main - Database path: data/trckr.db
2025-12-09 16:32:11 [INFO] server.main - Database initialized
2025-12-09 16:32:11 [INFO] server.logging_config - Logging configured at INFO level
```
Sync operation:
```
2025-12-09 16:32:15 [INFO] server.routes.sync - Sync started: client_id=abc12345..., last_sync_version=42, changes=3
2025-12-09 16:32:15 [DEBUG] server.routes.sync - Processing change: create issue def45678...
2025-12-09 16:32:15 [INFO] server.routes.sync - Sync completed: applied=3, conflicts=0, server_changes=5, server_version=45
```
Client sync:
```
2025-12-09 16:32:15 [INFO] client.sync - Starting sync: last_version=42, pending=3
2025-12-09 16:32:15 [DEBUG] client.sync - Collected 3 pending changes
2025-12-09 16:32:15 [INFO] client.sync - Sync completed: applied=3, conflicts=0, received=5, server_version=45
```