mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-08-07 11:21:11 +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
+11
-1
@@ -7,7 +7,10 @@ import threading
|
||||
from logging.handlers import QueueHandler
|
||||
from typing import Callable, Optional
|
||||
|
||||
from setproctitle import setproctitle
|
||||
|
||||
import frigate.log
|
||||
from frigate.config.logger import LoggerConfig
|
||||
|
||||
|
||||
class BaseProcess(mp.Process):
|
||||
@@ -50,7 +53,9 @@ class Process(BaseProcess):
|
||||
def before_start(self) -> None:
|
||||
self.__log_queue = frigate.log.log_listener.queue
|
||||
|
||||
def pre_run_setup(self) -> None:
|
||||
def pre_run_setup(self, logConfig: LoggerConfig | None = None) -> None:
|
||||
setproctitle(self.name)
|
||||
threading.current_thread().name = f"process:{self.name}"
|
||||
faulthandler.enable()
|
||||
|
||||
def receiveSignal(signalNumber, frame):
|
||||
@@ -68,3 +73,8 @@ class Process(BaseProcess):
|
||||
self.logger = logging.getLogger(self.name)
|
||||
logging.basicConfig(handlers=[], force=True)
|
||||
logging.getLogger().addHandler(QueueHandler(self.__log_queue))
|
||||
|
||||
if logConfig:
|
||||
frigate.log.apply_log_levels(
|
||||
logConfig.default.value.upper(), logConfig.logs
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user