|
84 | 84 | * [Quick Start](#-quick-start) |
85 | 85 | * [How It Works](#-how-it-works) |
86 | 86 | * [Usage Examples](#-usage-examples) |
| 87 | +* [Logging and Debugging](#-logging-and-debugging) |
87 | 88 | * [Documentation](#-documentation) |
88 | 89 | * [Examples & Tests](#-examples--tests) |
89 | 90 | * [Benchmarks](#-benchmarks) |
@@ -312,6 +313,141 @@ targets: |
312 | 313 |
|
313 | 314 | <br/> |
314 | 315 |
|
| 316 | +## 🔍 Logging and Debugging |
| 317 | +
|
| 318 | +go-broadcast provides comprehensive logging capabilities designed for debugging, monitoring, and troubleshooting. The logging system features intuitive verbose flags, component-specific debug modes, and automatic sensitive data redaction. |
| 319 | +
|
| 320 | +### Quick Start |
| 321 | +
|
| 322 | +```bash |
| 323 | +# Basic verbose output (-v for debug, -vv for trace, -vvv for trace with line numbers) |
| 324 | +go-broadcast sync -v # Debug level logging |
| 325 | +go-broadcast sync -vv # Trace level logging |
| 326 | +go-broadcast sync -vvv # Trace with caller info |
| 327 | + |
| 328 | +# Component-specific debugging |
| 329 | +go-broadcast sync --debug-git # Show git command details |
| 330 | +go-broadcast sync --debug-api # Show GitHub API requests/responses |
| 331 | +go-broadcast sync --debug-transform # Show file transformation details |
| 332 | +go-broadcast sync --debug-config # Show configuration validation |
| 333 | +go-broadcast sync --debug-state # Show state discovery process |
| 334 | + |
| 335 | +# Combine for comprehensive debugging |
| 336 | +go-broadcast sync -vv --debug-git --debug-api |
| 337 | + |
| 338 | +# JSON output for log aggregation |
| 339 | +go-broadcast sync --log-format json |
| 340 | + |
| 341 | +# Collect diagnostic information |
| 342 | +go-broadcast diagnose > diagnostics.json |
| 343 | +``` |
| 344 | + |
| 345 | +### Log Levels |
| 346 | + |
| 347 | +- **ERROR**: Critical failures that prevent operation |
| 348 | +- **WARN**: Important issues that don't stop execution |
| 349 | +- **INFO**: High-level operation progress (default) |
| 350 | +- **DEBUG**: Detailed operation information (`-v`) |
| 351 | +- **TRACE**: Very detailed debugging information (`-vv`) |
| 352 | + |
| 353 | +### Advanced Logging Features |
| 354 | + |
| 355 | +#### Performance Monitoring |
| 356 | +All operations are timed automatically. Look for `duration_ms` in logs: |
| 357 | +```bash |
| 358 | +# Find slow operations |
| 359 | +go-broadcast sync --log-format json 2>&1 | \ |
| 360 | + jq -r 'select(.duration_ms > 5000) | "\(.operation): \(.duration_ms)ms"' |
| 361 | +``` |
| 362 | + |
| 363 | +#### Security and Compliance |
| 364 | +- All tokens and secrets are automatically redacted |
| 365 | +- Audit trail for configuration changes and repository access |
| 366 | +- No sensitive data is ever logged |
| 367 | + |
| 368 | +#### Troubleshooting Common Issues |
| 369 | + |
| 370 | +**Git Authentication Issues** |
| 371 | +```bash |
| 372 | +# Debug git authentication problems |
| 373 | +go-broadcast sync -v --debug-git |
| 374 | + |
| 375 | +# Common indicators: |
| 376 | +# - "Authentication failed" in git output |
| 377 | +# - "Permission denied" errors |
| 378 | +# - Check GH_TOKEN or GITHUB_TOKEN environment variables |
| 379 | +``` |
| 380 | + |
| 381 | +**API Rate Limiting** |
| 382 | +```bash |
| 383 | +# Monitor API usage |
| 384 | +go-broadcast sync --debug-api --log-format json 2>&1 | \ |
| 385 | + jq 'select(.component=="github-api") | {operation, duration_ms, error}' |
| 386 | +``` |
| 387 | + |
| 388 | +**File Transformation Issues** |
| 389 | +```bash |
| 390 | +# Debug variable replacements and transformations |
| 391 | +go-broadcast sync -vv --debug-transform |
| 392 | + |
| 393 | +# Shows: |
| 394 | +# - Variables being replaced |
| 395 | +# - File size changes |
| 396 | +# - Before/after content for small files (with -vvv) |
| 397 | +``` |
| 398 | + |
| 399 | +**State Discovery Problems** |
| 400 | +```bash |
| 401 | +# Understand what go-broadcast sees in repositories |
| 402 | +go-broadcast sync --debug-state |
| 403 | + |
| 404 | +# Shows: |
| 405 | +# - Source repository state |
| 406 | +# - Target repository states |
| 407 | +# - Existing PR detection |
| 408 | +# - File discovery process |
| 409 | +``` |
| 410 | + |
| 411 | +### Log Management |
| 412 | + |
| 413 | +#### Structured Logging |
| 414 | +JSON format is ideal for log aggregation systems: |
| 415 | +```bash |
| 416 | +# Send to log aggregation |
| 417 | +go-broadcast sync --log-format json 2>&1 | fluentd |
| 418 | + |
| 419 | +# Parse with jq |
| 420 | +go-broadcast sync --log-format json 2>&1 | jq '.level="error"' |
| 421 | + |
| 422 | +# Save debug session |
| 423 | +go-broadcast sync -vvv --debug-git 2> debug-$(date +%Y%m%d-%H%M%S).log |
| 424 | +``` |
| 425 | + |
| 426 | +#### Performance Analysis |
| 427 | +```bash |
| 428 | +# Find slowest operations |
| 429 | +go-broadcast sync --log-format json 2>&1 | \ |
| 430 | + jq -r 'select(.duration_ms) | "\(.duration_ms)ms \(.operation)"' | \ |
| 431 | + sort -rn | head -20 |
| 432 | + |
| 433 | +# Monitor memory usage (if implemented) |
| 434 | +go-broadcast sync --log-format json 2>&1 | \ |
| 435 | + jq 'select(.memory_mb) | {operation, memory_mb}' |
| 436 | +``` |
| 437 | + |
| 438 | +### Environment Variables |
| 439 | + |
| 440 | +| Variable | Description | Example | |
| 441 | +|---------------------------|------------------------|---------| |
| 442 | +| `GO_BROADCAST_LOG_LEVEL` | Default log level | `debug` | |
| 443 | +| `GO_BROADCAST_LOG_FORMAT` | Default log format | `json` | |
| 444 | +| `GO_BROADCAST_DEBUG` | Enable all debug flags | `true` | |
| 445 | +| `NO_COLOR` | Disable colored output | `1` | |
| 446 | + |
| 447 | +For more detailed information, see the [comprehensive logging guide](docs/logging.md) and [troubleshooting runbook](docs/troubleshooting-runbook.md). |
| 448 | + |
| 449 | +<br/> |
| 450 | + |
315 | 451 | ## 📚 Documentation |
316 | 452 |
|
317 | 453 | - **Quick Start** – Get up and running in 5 minutes with the [Quick Start guide](#-quick-start) |
|
0 commit comments