improved logging
This commit is contained in:
@@ -5,9 +5,12 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass, field
|
||||
import hashlib
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class ComboModel:
|
||||
@@ -276,6 +279,18 @@ class GprModel:
|
||||
rx_geometry: list[GprRxGeometryModel] = field(default_factory=list)
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class LoggingModel:
|
||||
"""Application logging settings shared by the GUI and headless daemon.
|
||||
|
||||
``level`` is the verbosity floor (one of DEBUG/INFO/WARNING/ERROR, case-insensitive);
|
||||
it is chosen from the UI log-level selector, applied to the ``python_app`` logger at
|
||||
startup, and persisted here so the same verbosity is restored on the next run.
|
||||
"""
|
||||
|
||||
level: str = "info"
|
||||
|
||||
|
||||
@dataclass(slots=True)
|
||||
class RunConfigModel:
|
||||
"""Top-level runtime config model consumed by C++ processes and GUI."""
|
||||
@@ -289,6 +304,7 @@ class RunConfigModel:
|
||||
gpr: GprModel = field(default_factory=GprModel)
|
||||
combos: list[ComboModel] = field(default_factory=list)
|
||||
control_button: ControlButtonModel = field(default_factory=ControlButtonModel)
|
||||
logging: LoggingModel = field(default_factory=LoggingModel)
|
||||
|
||||
LIBREVNA_MODEL = "librevna"
|
||||
LIBREVNA_MULTI_MODEL = "librevna_multi"
|
||||
@@ -427,7 +443,11 @@ class RunConfigModel:
|
||||
|
||||
@classmethod
|
||||
def load_from_path(cls, path: Path) -> RunConfigModel:
|
||||
"""Load JSON file from disk and decode into model."""
|
||||
"""Load a JSON file from disk and decode it into a model.
|
||||
|
||||
Raises ValueError when the file's JSON root is not an object.
|
||||
"""
|
||||
logger.debug("Loading run config from %s", path)
|
||||
payload = json.loads(path.read_text(encoding="utf-8"))
|
||||
if not isinstance(payload, dict):
|
||||
raise ValueError(f"Config root must be JSON object: {path}")
|
||||
|
||||
Reference in New Issue
Block a user