Merge pull request #219 from coleam00/fix/respect-log-level-env-var

Fix LOG_LEVEL environment variable not being respected
This commit is contained in:
Wirasm 2025-08-16 00:39:35 +03:00 committed by GitHub
commit 41c58e53dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,15 +110,23 @@ def setup_logfire(
if not handlers:
handlers.append(logging.StreamHandler())
# Read LOG_LEVEL from environment
log_level = os.getenv("LOG_LEVEL", "INFO").upper()
# Configure root logging
logging.basicConfig(
level=logging.INFO,
level=getattr(logging, log_level, logging.INFO),
format="%(asctime)s | %(name)s | %(levelname)s | %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
handlers=handlers,
force=True,
)
# Suppress noisy third-party library logs
# These libraries log low-level details that are rarely useful
logging.getLogger("hpack").setLevel(logging.WARNING)
logging.getLogger("httpcore").setLevel(logging.WARNING)
_logfire_configured = True
logging.info(
f"📋 Logging configured (Logfire: {'enabled' if _logfire_enabled else 'disabled'})"