import os
import logging

import logfire

logfire.configure(service_name="ChatOCP", send_to_logfire=False)
logging.basicConfig(handlers=[logfire.LogfireLoggingHandler()])

log_level = os.environ.get("LOG_LEVEL", "WARNING")
numeric_level = getattr(logging, log_level.upper(), None)
if not isinstance(numeric_level, int):
    raise ValueError("Invalid log level: %s" % log_level)
logging.getLogger("api").setLevel(numeric_level)
