-
Notifications
You must be signed in to change notification settings - Fork 0
Logging
Comprehensive logging system for StreamTV.
All logs are in: ~/Library/Logs/StreamTV/
# View latest logs (live)
./scripts/view-logs.sh
# OR directly with tail
tail -f ~/Library/Logs/StreamTV/streamtv-$(date +%Y-%m-%d).log
# Open log folder in Finder
open ~/Library/Logs/StreamTV/
# Search for errors
./scripts/view-logs.sh search ERROR
# List all log files
./scripts/view-logs.sh listβ
Server startup/shutdown
β
All API requests and responses
β
Channel streaming events
β
Authentication attempts
β
FFmpeg operations
β
Database operations
β
Error messages with full tracebacks
β
System information
Every log line shows:
- Timestamp (YYYY-MM-DD HH:MM:SS)
- Module name
- Log level (INFO, WARNING, ERROR, etc.)
- Message
Example:
2025-12-04 14:30:45 - streamtv.main - INFO - StreamTV started on 0.0.0.0:8410
Edit config.yaml:
logging:
level: DEBUG # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL- DEBUG: Very detailed (use for troubleshooting)
- INFO: Standard level (recommended)
- WARNING: Only warnings and errors
- ERROR: Only errors and critical issues
Make sure the application has been started at least once. The log directory is created automatically when StreamTV starts.
Change log level to WARNING or ERROR in config.yaml.
# Create a zip archive of all logs
cd ~/Library/Logs/
zip -r StreamTV-logs.zip StreamTV/For complete logging documentation, see: LOGGING.md
grep -i "stream" ~/Library/Logs/StreamTV/*.log | grep -i errorgrep -i "auth" ~/Library/Logs/StreamTV/*.log | grep -i errorgrep -i "ffmpeg" ~/Library/Logs/StreamTV/*.logπ‘ Tip: Keep a terminal window open with ./scripts/view-logs.sh running while developing to see real-time logs!
A complete logging system has been successfully implemented for StreamTV that captures all Terminal log output and writes it to ~/Library/Logs/StreamTV/.
-
Created:
streamtv/utils/logging_setup.py(comprehensive logging module) -
Updated:
streamtv/main.py(integrated logging system) -
Features:
- β Dual output (console + file)
- β Automatic directory creation
- β Log rotation (10 MB max, 10 backups)
- β UTF-8 encoding
- β Configurable log levels
- β System information capture
- β Exception tracking with full stack traces
-
Created:
scripts/view-logs.sh(interactive log viewer) -
Created:
scripts/test_logging.py(logging system test) -
Features:
- β Live log tailing
- β Search functionality
- β List all logs
- β Open in Finder
- β View today's log
- β Color-coded output
-
Created:
LOGGING.md(complete guide) -
Created:
LOGGING_QUICKSTART.md(quick reference) -
Created:
LOGGING_SYSTEM_SUMMARY.md(technical details) -
Created:
LOGGING_IMPLEMENTATION_COMPLETE.md(completion report) -
Created:
LOGGING_COMPLETE_SUMMARY.md(this file) -
Updated:
README.md(added logging section)
~/Library/Logs/StreamTV/
βββ streamtv-2025-12-03.log (58 KB)
Current Status: β Operational with 58 KB of logs captured
# Option 1: Use the script (recommended)
./scripts/view-logs.sh
# Option 2: Direct tail
tail -f ~/Library/Logs/StreamTV/streamtv-*.log./scripts/view-logs.sh search ERROR./scripts/view-logs.sh listopen ~/Library/Logs/StreamTV/2025-12-03 18:05:36 - streamtv.main - INFO - StreamTV started on 0.0.0.0:8410
2025-12-03 18:05:36 - streamtv.main - INFO - Database initialized
2025-12-03 18:05:36 - streamtv.utils.logging_setup - INFO - Python version: 3.13.3
2025-12-03 18:05:36 - streamtv.utils.logging_setup - INFO - Platform: macOS-26.1-arm64
2025-12-03 18:05:36 - streamtv.utils.logging_setup - INFO - Machine: arm64
2025-12-03 18:05:36 - streamtv.streaming.channel_manager - INFO - Started continuous stream for channel 1980
2025-12-03 18:05:36 - streamtv.streaming.channel_manager - INFO - Initialized playout timeline for channel 1984
2025-12-03 18:05:36 - streamtv.streaming.channel_manager - INFO - Streaming playout for channel 1984 with 1000 items
2025-12-03 18:05:36 - streamtv.streaming.channel_manager - INFO - Channel 1984 using ON-DEMAND mode
2025-12-03 18:05:36 - streamtv.hdhomerun.ssdp_server - INFO - SSDP server started on port 1900
2025-12-03 18:05:36 - streamtv.main - INFO - HDHomeRun SSDP server started
2025-12-03 18:05:36 - streamtv.scheduling.parser - INFO - Parsed schedule: MN 1980 Winter Olympics with 11 content items
2025-12-03 18:05:36 - streamtv.scheduling.engine - INFO - Generated 1000 items from schedule
Every log entry follows this format:
YYYY-MM-DD HH:MM:SS - module.name - LEVEL - Message
Example:
2025-12-03 18:05:36 - streamtv.main - INFO - StreamTV started on 0.0.0.0:8410
β β β β
β β β ββ Message content
β β βββββββββ Log level
β ββββββββββββββββββββββββββ Module name
ββββββββββββββββββββββββββββββββββββββββββββ Timestamp
A comprehensive logging system has been successfully implemented for StreamTV. All application events, errors, and information are now automatically logged to ~/Library/Logs/StreamTV/ in addition to console output.
-
streamtv/utils/logging_setup.py- Main logging configuration module
- Handles dual output (console + file)
- Automatic log rotation
- System information logging
- Exception tracking with full tracebacks
-
streamtv/main.py(Updated)- Integrated new logging system
- System info logging at startup
- Custom uvicorn log configuration
-
scripts/view-logs.shβ- Interactive log viewer with multiple modes
- Commands: list, tail, search, today, open
- Color-coded output
- Made executable
-
scripts/test_logging.py- Test script to verify logging system
- Tests all log levels
- Exception logging test
- Log file detection and reporting
- Made executable
-
LOGGING.md- Complete logging documentation
- Usage examples
- Troubleshooting patterns
- Privacy and security considerations
- Configuration options
-
LOGGING_QUICKSTART.md- Quick reference guide
- Common commands
- Quick troubleshooting tips
- One-page reference
-
LOGGING_SYSTEM_SUMMARY.md- Implementation overview
- Feature list
- What gets logged
- Configuration details
-
LOGGING_IMPLEMENTATION_COMPLETE.md(This file)- Final summary of implementation
- Quick start instructions
- File listing
-
README.md(Updated)- Added logging system section
- Quick commands
- Documentation links
./scripts/view-logs.sh./scripts/view-logs.sh list./scripts/view-logs.sh search ERRORopen ~/Library/Logs/StreamTV/OR
./scripts/view-logs.sh open./scripts/view-logs.sh today# Live tail
tail -f ~/Library/Logs/StreamTV/streamtv-$(date +%Y-%m-%d).log
# View entire log
cat ~/Library/Logs/StreamTV/streamtv-$(date +%Y-%m-%d).log
# Search all logs
grep -r "search term" ~/Library/Logs/StreamTV/The logging system has been tested and verified:
./scripts/test_logging.pyTest Results: β All tests passed
- β
Log directory created at
~/Library/Logs/StreamTV/ - β Console output working
- β File output working
- β All log levels functioning (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- β Exception logging with tracebacks working
- β System information logging working
- β Log rotation configured
- β
Log file created:
streamtv-2025-12-03.log(58 KB)
The system captures:
A comprehensive logging system has been implemented for StreamTV that captures all application events and writes them to both the console and log files in ~/Library/Logs/StreamTV/.
File: streamtv/utils/logging_setup.py
Features:
- Dual output to console and file
- Automatic log directory creation in
~/Library/Logs/StreamTV/ - Log rotation (10 MB max per file, 10 backups)
- Configurable log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- System information logging
- Exception logging with full tracebacks
- UTF-8 encoding support
File: streamtv/main.py
Changes:
- Replaced basic
logging.basicConfig()with comprehensivesetup_logging() - Added system information logging at startup
- Configured uvicorn to use custom logging
File: scripts/view-logs.sh
A convenient shell script for viewing logs with multiple modes:
./scripts/view-logs.sh # Live tail of latest log
./scripts/view-logs.sh list # List all log files
./scripts/view-logs.sh today # View today's log
./scripts/view-logs.sh search # Search logs
./scripts/view-logs.sh open # Open in FinderFile: scripts/test_logging.py
A Python test script to verify the logging system is working correctly.
Created three documentation files:
-
LOGGING.md- Complete logging documentation -
LOGGING_QUICKSTART.md- Quick reference guide -
LOGGING_SYSTEM_SUMMARY.md- This file
Primary Location: ~/Library/Logs/StreamTV/
This is the standard macOS location for application logs, making them easily accessible through:
- Console.app (built-in macOS log viewer)
- Terminal commands
- Finder
- The provided view-logs.sh script
Filename Pattern: streamtv-YYYY-MM-DD.log
Log Entry Format:
YYYY-MM-DD HH:MM:SS - module.name - LEVEL - Message
Example:
2025-12-03 18:05:36 - streamtv.main - INFO - StreamTV started on 0.0.0.0:8410
2025-12-03 18:05:36 - streamtv.streaming.channel_manager - INFO - Started continuous stream for channel 1980
The system now logs:
β Application Lifecycle
- Server startup/shutdown
- Configuration loading
- Database initialization
- SSDP server status
β Channel Operations
- Channel creation/updates
- Stream start/stop events
- Playout initialization
- Timeline generation
β Streaming Events
- FFmpeg operations
- Transcoding status
- Stream health
- Client connections
β API Activity
- HTTP requests/responses
- Authentication attempts
- Rate limiting
- CORS enforcement
β Database Operations
- Query execution (DEBUG level)
- Transaction status
- Database errors
β System Information
- Python version
- Platform details
- Working directory
- Environment configuration
β Errors and Exceptions
- Full stack traces
- Error context
- Warning conditions
- Rotation: Files rotate at 10 MB
- Retention: Keep 10 backup files per day
- Encoding: UTF-8 for proper character support
- Buffering: Non-blocking async I/O
# Remove logs older than 30 days
find ~/Library/Logs/StreamTV/ -name "*.log*" -mtime +30 -delete# Using the script (recommended)
./scripts/view-logs.sh
# OR directly
tail -f ~/Library/Logs/StreamTV/streamtv-$(date +%Y-%m-%d).log./scripts/view-logs.sh search ERROR
---
## Related Pages
- [Scripts and Tools](Scripts-and-Tools)
- [Home](Home)