Added complete logging infrastructure for AI-only development debugging: **Core Logging Features:** - Command-line debug flags: -d (console) and -d filename (file output) - Custom log format: "message - severity - timestamp" - Professional Python logging with hierarchical loggers (bifrost.module) - Clean separation: debug mode vs production (warnings/errors only) **Comprehensive Coverage - Replaced 55+ Print Statements:** - timeline_view.py: Timeline operations, new content detection, sound events - main_window.py: Auto-refresh system, streaming mode, UI events - activitypub/client.py: API calls, streaming connections, server detection - audio/sound_manager.py: Sound playback, pack loading, volume control - error_manager.py: Centralized error handling with proper log levels - All remaining modules: Complete print statement elimination **Enhanced Auto-Refresh Debugging:** - Fixed repetitive refresh interval logging (only logs on changes) - Added detailed auto-refresh execution tracing with timing - New content detection logging with post ID tracking - Sound event logging showing which sounds play and why **Sound System Visibility:** - Complete audio event logging with file paths and volumes - Sound pack loading and fallback detection - Audio playback success/failure with detailed error context **Documentation Updates:** - README.md: Complete debug system documentation for users - CLAUDE.md: Professional logging guidelines for AI development - Comprehensive usage examples and troubleshooting guides This logging system provides essential debugging capabilities for the AI-only development constraint, enabling systematic issue resolution without human code intervention. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
119 lines
3.3 KiB
Python
Executable File
119 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Bifrost - Accessible Fediverse Client
|
|
A fully accessible ActivityPub client designed for screen reader users.
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import argparse
|
|
import logging
|
|
from pathlib import Path
|
|
|
|
# Force unbuffered output
|
|
sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
|
|
sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 1)
|
|
|
|
# Add src directory to Python path
|
|
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
|
|
from PySide6.QtWidgets import QApplication
|
|
from PySide6.QtCore import Qt
|
|
from main_window import MainWindow
|
|
|
|
|
|
class BifrostFormatter(logging.Formatter):
|
|
"""Custom formatter with format: message - severity - timestamp"""
|
|
|
|
def format(self, record):
|
|
# Format: message - severity - timestamp
|
|
timestamp = self.formatTime(record, "%Y-%m-%d %H:%M:%S")
|
|
return f"{record.getMessage()} - {record.levelname} - {timestamp}"
|
|
|
|
|
|
def setup_logging(debug_target=None):
|
|
"""Set up logging based on debug target"""
|
|
logger = logging.getLogger('bifrost')
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
# Clear any existing handlers
|
|
logger.handlers.clear()
|
|
|
|
formatter = BifrostFormatter()
|
|
|
|
if debug_target is None:
|
|
# No debug mode - only show warnings and errors to console
|
|
handler = logging.StreamHandler(sys.stderr)
|
|
handler.setLevel(logging.WARNING)
|
|
handler.setFormatter(formatter)
|
|
logger.addHandler(handler)
|
|
elif debug_target == 'console':
|
|
# Debug to console
|
|
handler = logging.StreamHandler(sys.stdout)
|
|
handler.setLevel(logging.DEBUG)
|
|
handler.setFormatter(formatter)
|
|
logger.addHandler(handler)
|
|
else:
|
|
# Debug to file
|
|
try:
|
|
handler = logging.FileHandler(debug_target, mode='w')
|
|
handler.setLevel(logging.DEBUG)
|
|
handler.setFormatter(formatter)
|
|
logger.addHandler(handler)
|
|
except Exception as e:
|
|
print(f"Error setting up file logging: {e}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
return logger
|
|
|
|
|
|
def parse_arguments():
|
|
"""Parse command line arguments"""
|
|
parser = argparse.ArgumentParser(
|
|
description="Bifrost - Accessible Fediverse Client",
|
|
formatter_class=argparse.RawDescriptionHelpFormatter
|
|
)
|
|
|
|
parser.add_argument(
|
|
'-d', '--debug',
|
|
nargs='?',
|
|
const='console',
|
|
metavar='FILE',
|
|
help='Enable debug logging. Use -d for console output or -d FILE for file output'
|
|
)
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
def main():
|
|
"""Main application entry point"""
|
|
args = parse_arguments()
|
|
|
|
# Set up logging
|
|
logger = setup_logging(args.debug)
|
|
|
|
logger.info("Bifrost application starting up")
|
|
|
|
app = QApplication(sys.argv)
|
|
app.setApplicationName("Bifrost")
|
|
app.setApplicationDisplayName("Bifrost Fediverse Client")
|
|
app.setApplicationVersion("1.0.0")
|
|
app.setOrganizationName("Bifrost")
|
|
app.setOrganizationDomain("bifrost.social")
|
|
|
|
# High DPI scaling is enabled by default in newer Qt versions
|
|
|
|
# Create and show main window
|
|
logger.debug("Creating MainWindow")
|
|
window = MainWindow()
|
|
logger.debug("MainWindow created, showing window")
|
|
window.show()
|
|
logger.debug("MainWindow shown, starting event loop")
|
|
|
|
# Run the application
|
|
sys.exit(app.exec())
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main() |