# Basic logging levels
go-broadcast sync --log-level debug # Debug level logging
go-broadcast sync --log-level info # Info level logging (default)
go-broadcast sync --log-level warn # Warning level logging
go-broadcast sync --log-level error # Error level logging
# System diagnostics
go-broadcast diagnose # Collect system info
# Configuration validation and testing
go-broadcast validate --config sync.yaml # Validate configuration
go-broadcast sync --dry-run --config sync.yaml # Preview changes
# Note: Verbose flags (-v, -vv, -vvv) and component-specific debug flags
# (--debug-git, --debug-api, etc.) are planned features not yet implemented.
# Current implementation supports --log-level for basic debugging.| Flag | Description | Output Level |
|---|---|---|
--log-level debug |
Debug level logging | DEBUG |
--log-level info |
Info level logging (default) | INFO |
--log-level warn |
Warning level logging | WARN |
--log-level error |
Error level logging | ERROR |
--dry-run |
Preview changes without executing | All levels |
--config <file> |
Specify configuration file | All levels |
Note: Advanced verbose flags (-v, -vv, -vvv) and component-specific debug flags (--debug-git, --debug-api, etc.) are planned features not yet implemented in the current version.
# Authentication issues
go-broadcast sync --log-level debug # Enable debug logging
echo $GITHUB_TOKEN | cut -c1-10 # Check token (first 10 chars)
gh auth status # Test GitHub CLI
# Configuration validation
go-broadcast validate --config sync.yaml
# Test configuration without changes
go-broadcast sync --dry-run --config sync.yaml
# Save debug session
go-broadcast sync --log-level debug 2> debug-$(date +%Y%m%d-%H%M%S).log
# System diagnostics
go-broadcast diagnose > diagnostics-$(date +%Y%m%d-%H%M%S).json| Variable | Default | Description |
|---|---|---|
GITHUB_TOKEN |
- | GitHub authentication token |
GH_TOKEN |
- | Alternative GitHub token variable |
NO_COLOR |
- | Disable colored output |
Note: Environment variables for log level and format are planned features not yet implemented.
go-broadcast provides comprehensive logging capabilities designed for debugging, monitoring, and troubleshooting. The logging system is built on structured logging principles with automatic sensitive data redaction.
- Core Logger: Built on logrus with custom enhancements
- Debug Subsystems: Component-specific debug flags
- Performance Metrics: Automatic operation timing
- Security Layer: Automatic sensitive data redaction
- Structured Output: JSON format for log aggregation
- stderr: All logs (keeps stdout clean for program output)
- stdout: User-facing messages only
- Files: Via shell redirection or log rotation tools
The current implementation provides basic log level control:
Shows detailed operation progress and debugging information:
time="13:32:17" level=debug msg="CLI initialized" config=examples/minimal.yaml dry_run=true
time="13:32:17" level=debug msg="Executing command" args="[auth status]" command=gh
time="13:32:17" level=debug msg="Command completed successfully" args="[auth status]" command=gh
Shows standard operational information:
time="13:32:17" level=info msg="Configuration changed" action=config_loaded component=audit
time="13:32:17" level=info msg="Syncing all configured targets" command=sync
time="13:32:17" level=info msg="Starting sync operation" component=sync_engine
Shows warnings and higher severity messages:
time="13:32:17" level=warning msg="DRY-RUN MODE: No changes will be made" component=sync_engine
Shows only error messages:
time="13:32:17" level=error msg="Command failed" args="[api repos/org/template-repo/branches/master]" command=gh
Note: Verbose flags (-v, -vv, -vvv) and component-specific debug flags (--debug-git, --debug-api, etc.) are planned features not yet implemented in the current version.
Detailed git command execution logging:
- Full command lines with arguments
- Working directory and environment
- Real-time stdout/stderr output
- Exit codes and timing
Example output:
DEBUG Executing git command command=/usr/bin/git args=[clone --depth=1] dir=/tmp/broadcast-123
[TRACE] stdout: Cloning into 'repo'...
[TRACE] stderr: Receiving objects: 100% (547/547), done.
DEBUG Git command completed duration_ms=2341 exit_code=0
GitHub API request/response logging:
- Request parameters and headers (redacted)
- Response sizes and timing
- Rate limit information
- Error details
Example output:
DEBUG GitHub CLI request args=[api repos/owner/repo] timestamp=2024-01-15T10:30:45Z
[TRACE] Request field field=state:open
DEBUG GitHub CLI response duration_ms=234 response_size=4096 error=<nil>
File transformation and template processing:
- Variable substitutions
- Content size changes
- Before/after comparisons (small files)
- Transform timing
Example output:
DEBUG Starting transformation content_size=1024 variables=5 type=text
[TRACE] Variable replacement variable={{REPO_NAME}} value=go-broadcast
DEBUG Transformation completed size_before=1024 size_after=1048 diff=24
Configuration loading and validation:
- Schema validation steps
- Default value application
- Environment variable resolution
- Validation errors with context
Example output:
DEBUG Starting config validation component=config
[TRACE] Validating version version=1.0
DEBUG Validating source configuration repo=owner/source branch=main path=.broadcast
DEBUG Validating targets target_count=3
Repository state discovery process:
- Source repository analysis
- Target repository scanning
- Pull request detection
- File mapping resolution
Example output:
DEBUG Discovering source repository state component=state-discovery
DEBUG Source state discovered commit=abc123 branch=main file_count=5
DEBUG Target state discovered target=owner/target has_pr=true base_match=false
[TRACE] Pull request details pr_number=42 pr_state=open pr_mergeable=true
Human-readable format with colors (when terminal supports):
15:04:05 INFO Starting broadcast sync version=1.2.3
15:04:05 DEBUG Config loaded successfully path=.broadcast.yaml targets=3
15:04:06 WARN Rate limit approaching remaining=100
Machine-readable format for log aggregation:
{
"@timestamp": "2024-01-15T15:04:05.123Z",
"level": "info",
"message": "Starting broadcast sync",
"component": "cli",
"version": "1.2.3",
"correlation_id": "a1b2c3d4"
}All operations are automatically timed with results in duration_ms:
{
"message": "Repository sync completed",
"operation": "repository_sync",
"duration_ms": 5234,
"duration_human": "5.234s",
"repo": "owner/target"
}# Find operations taking more than 5 seconds
go-broadcast sync --log-format json 2>&1 | \
jq 'select(.duration_ms > 5000) | {operation, duration_ms, repo}'
# Summary of operation times
go-broadcast sync --log-format json 2>&1 | \
jq -r 'select(.duration_ms) | "\(.operation)"' | \
sort | uniq -c | sort -rnThe following patterns are automatically redacted:
- GitHub tokens (ghp_, ghs_, github_pat_, ghr_)
- Bearer tokens and API keys
- Password/secret/key parameters in URLs
- Base64 encoded secrets
- Environment variables containing TOKEN/SECRET/KEY
Input:
Executing command with token=ghp_1234567890abcdef1234567890abcdef1234
Output:
Executing command with token=ghp_***REDACTED***
Security-relevant operations are logged with audit markers:
{
"event": "config_change",
"user": "system",
"action": "update",
"component": "audit",
"time": 1705330245
}The diagnose command collects system information for troubleshooting:
go-broadcast diagnoseOutput includes:
- System information (OS, architecture, CPU count)
- go-broadcast --version and build info
- Git and GitHub CLI versions
- Environment variables (redacted)
- Configuration file status
- Basic connectivity tests
Example output:
{
"timestamp": "2024-01-15T15:04:05Z",
"version": {
"version": "1.2.3",
"commit": "abc123def",
"date": "2024-01-15"
},
"system": {
"os": "darwin",
"arch": "arm64",
"num_cpu": 8,
"go_version": "go1.21.5"
},
"git_version": "git version 2.43.0",
"gh_cli_version": "gh version 2.40.0 (2024-01-10)",
"config": {
"path": ".broadcast.yaml",
"exists": true,
"valid": true
}
}# Enable verbose output to see what's happening
go-broadcast sync -v
# Check if logs are going to stderr
go-broadcast sync 2>&1 | less# Debug git authentication
go-broadcast sync --debug-git -v
# Check token is set
echo $GITHUB_TOKEN | cut -c1-10 # Should show first 10 chars
# Test GitHub CLI directly
gh auth status# Find slow operations
go-broadcast sync --log-format json 2>&1 | \
jq -r 'select(.duration_ms > 1000) | "\(.duration_ms)ms \(.operation) \(.repo // "")"'
# Enable all debugging to see where time is spent
go-broadcast sync -vv --debug-git --debug-api# Monitor memory during execution (if supported by OS)
/usr/bin/time -l go-broadcast sync 2>&1 | grep "maximum resident set size"
# Use JSON logs to track memory if implemented
go-broadcast sync --log-format json 2>&1 | \
jq 'select(.memory_mb) | {time: .["@timestamp"], memory_mb, operation}'# Set up detailed logging for problem repository
export GO_BROADCAST_LOG_LEVEL=trace
go-broadcast sync --debug-state --debug-git -vv 2> debug-repo.log
# Analyze the log
grep "target=owner/problem-repo" debug-repo.log- Use
-vvduring development for detailed feedback - Enable relevant debug flags for the area you're working on
- Use JSON format when debugging with scripts
- Save debug logs for complex issues:
2> debug-$(date +%Y%m%d-%H%M%S).log
- Default INFO level for normal operation
- Use JSON format for log aggregation
- Enable debug selectively for specific issues
- Monitor performance metrics regularly
- Set up log rotation to prevent disk fill
# Using rotatelogs
go-broadcast sync --log-format json 2>&1 | \
rotatelogs -l /var/log/go-broadcast/app.log 86400
# Using system logrotate
cat > /etc/logrotate.d/go-broadcast << EOF
/var/log/go-broadcast/*.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
}
EOF# Extract metrics from JSON logs
go-broadcast sync --log-format json 2>&1 | \
go-broadcast-prometheus-exporter
# Metrics available:
# - go_broadcast_operation_duration_seconds
# - go_broadcast_operation_total
# - go_broadcast_errors_total# Logstash configuration
input {
pipe {
command => "go-broadcast sync --log-format json"
codec => json
}
}
filter {
if [component] {
mutate {
add_tag => [ "go-broadcast" ]
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "go-broadcast-%{+YYYY.MM.dd}"
}
}| Field | Description | Example |
|---|---|---|
@timestamp |
ISO 8601 timestamp | 2024-01-15T15:04:05.123Z |
level |
Log level | info, debug, trace |
message |
Log message | Starting sync operation |
component |
System component | sync-engine, git, transform |
operation |
Current operation | repository_sync, git_clone |
duration_ms |
Operation duration | 1234 |
error |
Error message | connection timeout |
repo |
Repository name | owner/repo |
correlation_id |
Request correlation ID | a1b2c3d4-e5f6-7890 |
command: Git command pathargs: Command argumentsexit_code: Process exit codedir: Working directory
request_size: Request body sizeresponse_size: Response body sizestatus_code: HTTP status coderate_limit_remaining: API calls remaining
content_size: Content size in bytesvariables: Number of variablestype: Transform typesize_before/size_after: Size comparison
- ✓ Enable appropriate verbose level (-v, -vv, -vvv)
- ✓ Enable relevant debug flags
- ✓ Check stderr for log output
- ✓ Use JSON format for detailed analysis
- ✓ Run diagnose command
- ✓ Save logs for support requests
- GitHub Issues: Include
go-broadcast diagnoseoutput - Community Forum: Share relevant log excerpts (redacted)
- Enterprise Support: Provide full debug logs via secure channel
For comprehensive go-broadcast development workflows, see CLAUDE.md which includes:
- Debug command procedures for troubleshooting go-broadcast issues
- Verbose logging workflows for development and debugging
- Component-specific debugging for targeted investigation
- Environment troubleshooting for setup and configuration issues
- Enhanced Troubleshooting Guide - Comprehensive troubleshooting with operational procedures
- Performance Guide - Performance optimization and monitoring
- CLAUDE.md Developer Workflows - Complete development workflow integration
- Main Documentation - Overview and quick start