#!/usr/bin/env python3
"""Test si le logging fonctionne dans les threads"""
import threading
import time
import logging

# Configuration logger identique à ai_predictor
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("TestThread")

def thread_function():
    """Fonction du thread"""
    logger.info("🔍 [THREAD] Thread started")
    print("🔍 [PRINT] Thread started")
    
    for i in range(3):
        logger.info(f"🔍 [THREAD] Cycle {i+1}")
        print(f"🔍 [PRINT] Cycle {i+1}")
        time.sleep(2)
    
    logger.info("🔍 [THREAD] Thread finished")
    print("🔍 [PRINT] Thread finished")

print("Creating thread...")
t = threading.Thread(target=thread_function, daemon=True)
print("Starting thread...")
t.start()
print(f"Thread alive: {t.is_alive()}")

print("Waiting 8 seconds...")
time.sleep(8)
print(f"Thread alive after wait: {t.is_alive()}")
print("Main thread finished")
