"""
Project logging utilities
Reference the qwen_agent logging implementation
"""

import logging
import os


def setup_logger(name='qwen_agent_project', level=None):
    """
    Configure the logger
    
    Args:
        name: logger name
        level: log level; defaults based on environment variable QWEN_AGENT_DEBUG
    
    Returns:
        logging.Logger: configured logger instance
    """
    if level is None:
        level = logging.DEBUG

    handler = logging.StreamHandler()
    # Use the same format as qwen_agent
    formatter = logging.Formatter('%(asctime)s - %(filename)s - %(lineno)d - %(levelname)s - %(message)s')
    handler.setFormatter(formatter)

    _logger = logging.getLogger(name)
    _logger.setLevel(level)
    
    # Avoid adding duplicate handlers
    if not _logger.handlers:
        _logger.addHandler(handler)
    
    return _logger


# Create the main project logger
logger = setup_logger()

# Create a dedicated tool invocation logger for easier filtering
tool_logger = setup_logger('qwen_agent_tools')

# Create a logger for the task queue
queue_logger = setup_logger('qwen_agent_queue')
