mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-29 18:04:42 +03:00
Ensure logging config is propagated to forked processes (#18704)
* Move log level initialization to log * Use logger config * Formatting * Fix config order * Set process names --------- Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
This commit is contained in:
committed by
Blake Blackshear
co-authored by
Nicolas Mowen
parent
a6b80c0f9c
commit
4deccf08a1
@@ -1,20 +1,11 @@
|
||||
import logging
|
||||
from enum import Enum
|
||||
|
||||
from pydantic import Field, ValidationInfo, model_validator
|
||||
from typing_extensions import Self
|
||||
|
||||
from frigate.log import LogLevel, apply_log_levels
|
||||
|
||||
from .base import FrigateBaseModel
|
||||
|
||||
__all__ = ["LoggerConfig", "LogLevel"]
|
||||
|
||||
|
||||
class LogLevel(str, Enum):
|
||||
debug = "debug"
|
||||
info = "info"
|
||||
warning = "warning"
|
||||
error = "error"
|
||||
critical = "critical"
|
||||
__all__ = ["LoggerConfig"]
|
||||
|
||||
|
||||
class LoggerConfig(FrigateBaseModel):
|
||||
@@ -26,18 +17,6 @@ class LoggerConfig(FrigateBaseModel):
|
||||
@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())
|
||||
apply_log_levels(self.default.value.upper(), self.logs)
|
||||
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user