MentraOS / mobile /LOG_VIEWING_GUIDE.md
Anirudh1950's picture
Add files using upload-large-folder tool
be462b3 verified
|
Raw History Blame Contribute Delete
3.56 kB

MentraOS Log Viewing Operations Manual

Mission: Enhanced Battlefield Visibility for Development Logs

Quick Deploy Commands

Standard Color-Coded Logs

bun run dev:logs

Benefits: Color-coded by subsystem (CORE, SOCKET, MAN, LIVE, MIC)

Filter Specific Subsystems

# Only show CORE logs
bun run start 2>&1 | ./scripts/log-viewer.sh | grep "CORE:"

# Only show MIC-related activity
bun run start 2>&1 | ./scripts/log-viewer.sh | grep "MIC:"

# Only show SOCKET communication
bun run start 2>&1 | ./scripts/log-filter.sh "SOCKET"

# Multiple subsystems
bun run start 2>&1 | ./scripts/log-filter.sh "CORE|SOCKET|LIVE"

Color Legend

Subsystem Color Purpose
CORE: Cyan Core system operations
SOCKET: Yellow WebSocket communications
MAN: Magenta Manager layer operations
LIVE: Green K900/Live streaming operations
MIC: Blue Microphone system
ERROR Red Error messages
WARN Orange Warning messages

Advanced Tactics

Save Logs to File While Viewing

bun run start 2>&1 | tee dev-session.log | ./scripts/log-viewer.sh

Live Search Within Logs

bun run dev:logs | less -R  # Use /pattern to search, 'n' for next match

Monitor Specific Patterns

# Watch for VAD events
bun run start 2>&1 | ./scripts/log-viewer.sh | grep -i "vad"

# Track BLE characteristic changes
bun run start 2>&1 | ./scripts/log-viewer.sh | grep -i "characteristic"

# Monitor view state changes
bun run start 2>&1 | ./scripts/log-viewer.sh | grep -i "view state"

Split View (Requires tmux)

# Terminal 1: Full logs
tmux new-session -s logs 'bun run dev:logs'

# Terminal 2: Only errors
tmux split-window -h 'bun run start 2>&1 | grep -i error'

Pro Tips

  1. Reduce Noise: Use grep -v to exclude patterns

    bun run dev:logs | grep -v "Updating view state"
    
  2. Focus on Errors: Quick error detection

    bun run start 2>&1 | ./scripts/log-viewer.sh | grep -E "(ERROR|Error|error)"
    
  3. Timestamp Logging: Add timestamps

    bun run start 2>&1 | while IFS= read -r line; do echo "$(date '+%H:%M:%S') $line"; done | ./scripts/log-viewer.sh
    
  4. Context Lines: Show lines around matches

    bun run start 2>&1 | ./scripts/log-viewer.sh | grep -A 3 -B 3 "ERROR"
    

Performance Notes

  • The log viewer script processes logs in real-time with minimal overhead
  • Piping through multiple filters may introduce slight latency
  • For high-volume logging sessions, consider writing to file first then filtering

Troubleshooting

Script not found?

chmod +x mobile/scripts/log-viewer.sh mobile/scripts/log-filter.sh

Colors not showing? Ensure your terminal supports ANSI colors (most modern terminals do).

Port conflicts? The dev scripts handle port selection automatically. If needed, kill existing processes:

lsof -ti:8081 | xargs kill -9

Mission Success Criteria

✅ Subsystems clearly identified by color
✅ Ability to filter specific operational areas
✅ Quick error detection and investigation
✅ Reduced cognitive load during development