Логирование вынесено в top-level import

This commit is contained in:
2026-07-25 10:51:10 +03:00
parent e48c97d83e
commit e588bf0c20
+5 -4
View File
@@ -1,3 +1,4 @@
import logging
from typing import List
from fastapi import APIRouter, Depends
@@ -7,6 +8,8 @@ from .. import models, schemas, proxmox_client as pve
from ..database import get_db
from ..deps import get_current_user, require_admin
logger = logging.getLogger(__name__)
router = APIRouter(prefix="/templates", tags=["templates"])
@@ -34,14 +37,12 @@ def list_proxmox_templates(_=Depends(require_admin)):
try:
vm_tpls = pve.list_vm_templates()
except Exception as exc:
import logging
logging.getLogger(__name__).warning("Ошибка получения VM-шаблонов из Proxmox: %s", exc)
logger.warning("Ошибка получения VM-шаблонов из Proxmox: %s", exc)
vm_tpls = []
try:
lxc_tpls = pve.list_lxc_templates()
except Exception as exc:
import logging
logging.getLogger(__name__).warning("Ошибка получения LXC-шаблонов из Proxmox: %s", exc)
logger.warning("Ошибка получения LXC-шаблонов из Proxmox: %s", exc)
lxc_tpls = []
return {"vm_templates": vm_tpls, "lxc_templates": lxc_tpls}