mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-07 11:21:11 +03:00
Fix logging (#14122)
Fixes logging without introducing more junk into FrigateApp.
This commit is contained in:
@@ -289,7 +289,9 @@ class FrigateConfig(FrigateBaseModel):
|
||||
default_factory=dict, title="Frigate environment variables."
|
||||
)
|
||||
logger: LoggerConfig = Field(
|
||||
default_factory=LoggerConfig, title="Logging configuration."
|
||||
default_factory=LoggerConfig,
|
||||
title="Logging configuration.",
|
||||
validate_default=True,
|
||||
)
|
||||
|
||||
# Global config
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import logging
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic import Field, ValidationInfo, model_validator
|
||||
from typing_extensions import Self
|
||||
|
||||
from .base import FrigateBaseModel
|
||||
|
||||
@@ -20,3 +22,17 @@ class LoggerConfig(FrigateBaseModel):
|
||||
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 = {
|
||||
"werkzeug": LogLevel.error,
|
||||
"ws4py": LogLevel.error,
|
||||
**self.logs,
|
||||
}
|
||||
|
||||
for log, level in log_levels.items():
|
||||
logging.getLogger(log).setLevel(level.value.upper())
|
||||
|
||||
Reference in New Issue
Block a user