"""View recent logs"""
import sys
import os

# Fix encoding for Windows
if sys.platform == 'win32':
    os.environ['PYTHONIOENCODING'] = 'utf-8'
    if hasattr(sys.stdout, 'reconfigure'):
        sys.stdout.reconfigure(encoding='utf-8')

try:
    with open('seabot.log', 'r', encoding='utf-8', errors='replace') as f:
        lines = f.readlines()
        
    # Get last 50 lines
    recent_lines = lines[-50:]
    
    print("=" * 60)
    print("RECENT LOGS (last 50 lines)")
    print("=" * 60)
    
    for line in recent_lines:
        # Remove emojis and special chars that cause encoding issues
        line = line.encode('ascii', 'ignore').decode('ascii')
        print(line.rstrip())
        
except FileNotFoundError:
    print("Log file not found: seabot.log")
except Exception as e:
    print(f"Error reading logs: {e}")
