logs and debugging - panuozzo77/StreamingCommunity GitHub Wiki

Logs and Debugging

This document explains how to use logging and debugging features in StreamingCommunity to diagnose and resolve issues.

Enabling Debug Mode

StreamingCommunity includes a debug mode that provides more detailed information about what's happening during execution.

Via Configuration File

To enable debug mode, edit your config.json file:

{
    "DEFAULT": {
        "debug": true
    }
}

Via Environment Variable

For the Telegram bot, you can enable debugging by setting the DEBUG environment variable in your .env file:

DEBUG=True

Log Output

When debug mode is enabled, the application will output detailed logs to:

  1. Console: Logs are displayed in the terminal
  2. Log Files: Depending on the component, logs may be written to files

Understanding Log Messages

Log messages typically follow this format:

[LEVEL] [TIMESTAMP] [MODULE] Message

Where:

  • LEVEL: Indicates the severity (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • TIMESTAMP: When the event occurred
  • MODULE: Which part of the application generated the message
  • Message: The actual log content

Log Levels

  • DEBUG: Detailed information, typically of interest only when diagnosing problems
  • INFO: Confirmation that things are working as expected
  • WARNING: Indication that something unexpected happened, but the application is still working
  • ERROR: Due to a more serious problem, the application has not been able to perform some function
  • CRITICAL: A serious error, indicating that the application itself may be unable to continue running

Common Debug Information

When debug mode is enabled, you'll see additional information about:

  1. Network Requests: URLs, headers, response codes
  2. API Responses: Raw data from streaming sites
  3. Parser Operations: Details about content extraction
  4. Download Progress: Detailed segment information
  5. FFmpeg Operations: Command lines and conversion details

Debugging Specific Components

Network Issues

To debug network-related issues:

  1. Enable debug mode
  2. Look for log entries related to requests and responses
  3. Check for HTTP status codes, timeouts, or connection errors
  4. Verify that URLs are correctly formed and accessible

Parser Issues

To debug content parsing issues:

  1. Enable debug mode
  2. Look for log entries from parser modules
  3. Check if the expected content structure was found
  4. Verify that selectors and extraction patterns are working

Download Issues

To debug download problems:

  1. Enable debug mode
  2. Look for log entries from downloader modules
  3. Check for segment download failures or timeouts
  4. Verify that M3U8 playlists are correctly parsed

FFmpeg Issues

To debug media processing problems:

  1. Enable debug mode
  2. Look for log entries related to FFmpeg commands
  3. Check for FFmpeg error codes or warnings
  4. Verify that FFmpeg is correctly installed and accessible

Advanced Debugging Techniques

Manual API Testing

You can manually test site APIs using tools like curl or Postman:

curl -v -H "User-Agent: Mozilla/5.0" "https://example-site.com/api/search?q=test"

Network Traffic Analysis

Use tools like Wireshark or the browser's Developer Tools to analyze network traffic:

  1. Open your browser's Developer Tools (F12)
  2. Go to the Network tab
  3. Visit the streaming site manually
  4. Observe the requests and responses

Python Debugging

For developers, you can add custom debug code:

import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

# Add debug points
logger.debug(f"Variable value: {variable}")

Telegram Bot Debugging

For Telegram bot issues:

  1. Set DEBUG=True in your .env file
  2. Check the console output for detailed logs
  3. Verify that the bot is correctly registered with Telegram
  4. Ensure your user ID is correctly set in the AUTHORIZED_USER_ID variable

Collecting Information for Bug Reports

When reporting bugs, include:

  1. Log Output: Full debug logs
  2. Configuration: Your config.json (with sensitive information removed)
  3. Environment: Python version, OS, and installed packages
  4. Steps to Reproduce: Detailed steps to recreate the issue
  5. Expected vs. Actual Behavior: What you expected and what happened instead

Related Documentation

⚠️ **GitHub.com Fallback** ⚠️