|
import logging
|
|
|
|
|
|
def setup_logger(name):
|
|
logger = logging.getLogger(name)
|
|
if not logger.handlers:
|
|
logger.setLevel(logging.INFO)
|
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
|
|
|
|
console_handler = logging.StreamHandler()
|
|
console_handler.setFormatter(formatter)
|
|
logger.addHandler(console_handler)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return logger
|
|
|
|
logger = setup_logger(__name__)
|
|
|
|
|
|
def log_generated_chat_id_with_referer(chat_id, model, referer_url):
|
|
"""
|
|
Log the generated Chat ID with model and referer URL if it exists.
|
|
"""
|
|
logger.info(f"Generated Chat ID: {chat_id} - Model: {model} - URL: {referer_url}")
|
|
|
|
def log_model_delay(delay_seconds, model, chat_id):
|
|
"""
|
|
Log the delay introduced for specific models.
|
|
"""
|
|
logger.info(f"Introducing a delay of {delay_seconds} seconds for model '{model}' (Chat ID: {chat_id})")
|
|
|
|
def log_http_error(error, chat_id):
|
|
"""
|
|
Log HTTP errors encountered during requests.
|
|
"""
|
|
logger.error(f"HTTP error occurred for Chat ID {chat_id}: {error}")
|
|
|
|
def log_request_error(error, chat_id):
|
|
"""
|
|
Log request errors unrelated to HTTP status.
|
|
"""
|
|
logger.error(f"Request error occurred for Chat ID {chat_id}: {error}")
|
|
|
|
def log_strip_prefix(model_prefix, content):
|
|
"""
|
|
Log when a model prefix is stripped from the content.
|
|
"""
|
|
logger.debug(f"Stripping prefix '{model_prefix}' from content.")
|
|
|