Add LOG_LEVEL env config and fix Nalogo receipt trigger

This commit is contained in:
machka pasla
2026-01-14 16:03:21 +03:00
parent 658139d607
commit 08aca3b28d
4 changed files with 35 additions and 2 deletions
+18 -1
View File
@@ -1,5 +1,6 @@
import asyncio
import logging
import os
import sys
from dotenv import load_dotenv
@@ -9,6 +10,21 @@ from config.settings import get_settings, Settings
from db.database_setup import init_db, init_db_connection
def _resolve_log_level(value: str) -> int:
if not value:
return logging.INFO
if isinstance(value, str):
normalized = value.strip()
if not normalized:
return logging.INFO
if normalized.isdigit():
return int(normalized)
level = getattr(logging, normalized.upper(), None)
if isinstance(level, int):
return level
return logging.INFO
async def main():
load_dotenv()
settings = get_settings()
@@ -25,8 +41,9 @@ async def main():
if __name__ == "__main__":
load_dotenv()
logging.basicConfig(
level=logging.INFO,
level=_resolve_log_level(os.getenv("LOG_LEVEL", "INFO")),
stream=sys.stdout,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
try: