Files
blakeblackshear.frigate/frigate/config/logger.py
Nicolas Mowen 765a28d812 Live classification model training (#18583)
* Implement model training via ZMQ and add model states to represent training

* Get model updates working

* Improve toasts and model state

* Clean up logging

* Add back in
2025-08-16 10:20:33 -05:00

44 lines
1.2 KiB
Python

import logging
from enum import Enum
from pydantic import Field, ValidationInfo, model_validator
from typing_extensions import Self
from .base import FrigateBaseModel
__all__ = ["LoggerConfig", "LogLevel"]
class LogLevel(str, Enum):
debug = "debug"
info = "info"
warning = "warning"
error = "error"
critical = "critical"
class LoggerConfig(FrigateBaseModel):
default: LogLevel = Field(default=LogLevel.info, title="Default logging level.")
logs: dict[str, LogLevel] = Field(
default_factory=dict, title="Log level for specified processes."
)
@model_validator(mode="after")
def post_validation(self, info: ValidationInfo) -> Self:
if isinstance(info.context, dict) and info.context.get("install", False):
logging.getLogger().setLevel(self.default.value.upper())
log_levels = {
"absl": LogLevel.error,
"httpx": LogLevel.error,
"tensorflow": LogLevel.error,
"werkzeug": LogLevel.error,
"ws4py": LogLevel.error,
**self.logs,
}
for log, level in log_levels.items():
logging.getLogger(log).setLevel(level.value.upper())
return self