From 70a81c86ba6c884c94dba78e3d2f2e17c06a414f Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 8 Mar 2025 13:16:25 +0100 Subject: [PATCH] feat: dynamically assign error console --- freqtrade/loggers/__init__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/freqtrade/loggers/__init__.py b/freqtrade/loggers/__init__.py index 162cfcc62..c6294370d 100644 --- a/freqtrade/loggers/__init__.py +++ b/freqtrade/loggers/__init__.py @@ -66,7 +66,6 @@ FT_LOGGING_CONFIG = { "handlers": { "console": { "class": "freqtrade.loggers.ft_rich_handler.FtRichHandler", - "console": error_console, "formatter": "basic", # "class": "logging.StreamHandler", # "formatter": "standard", @@ -101,9 +100,12 @@ def _create_log_config(config: Config) -> dict[str, Any]: # Get log_config from user config or use default log_config = config.get("log_config", FT_LOGGING_CONFIG.copy()) - logfile = config.get("logfile") + # Dynamically update any FtRichHandler with the error_console + for handler_config in log_config.get("handlers", {}).values(): + if handler_config.get("class") == "freqtrade.loggers.ft_rich_handler.FtRichHandler": + handler_config["console"] = error_console - if logfile: + if logfile := config.get("logfile"): s = logfile.split(":") if s[0] == "syslog": # Add syslog handler to the config