Show only whitelist warnings

This commit is contained in:
mrpabloyeah
2025-04-13 12:27:19 +02:00
parent 3d1568783e
commit 33105a996e
3 changed files with 14 additions and 10 deletions

View File

@@ -9,8 +9,8 @@ class LoggingMixin:
Shows similar messages only once every `refresh_period`.
"""
# Disable INFO output when False
show_info_output = True
# Disable output completely
show_output = True
def __init__(self, logger, refresh_period: int = 3600):
"""
@@ -35,10 +35,6 @@ class LoggingMixin:
# Log as debug first
self.logger.debug(message)
# Determine if this is an INFO level message
is_info_message = getattr(logmethod, "__name__", "") == "info"
# For INFO messages, respect show_info_output flag
if not is_info_message or self.show_info_output:
# Call hidden function.
if self.show_output:
_log_once(message)

View File

@@ -114,7 +114,7 @@ class Backtesting:
"""
def __init__(self, config: Config, exchange: Exchange | None = None) -> None:
LoggingMixin.show_info_output = False
LoggingMixin.show_output = False
self.config = config
self.results: BacktestResultType = get_BacktestResultType_default()
self.trade_id_counter: int = 0
@@ -235,7 +235,7 @@ class Backtesting:
@staticmethod
def cleanup():
LoggingMixin.show_info_output = True
LoggingMixin.show_output = True
enable_database_use()
def init_backtest_detail(self) -> None:

View File

@@ -237,6 +237,11 @@ class IPairList(LoggingMixin, ABC):
:return: the list of pairs the user wants to trade without those unavailable or
black_listed
"""
# Save show_output value and set it to True
prev_show_output = self.show_output
self.show_output = True
markets = self._exchange.markets
if not markets:
raise OperationalException(
@@ -277,5 +282,8 @@ class IPairList(LoggingMixin, ABC):
if pair not in sanitized_whitelist:
sanitized_whitelist.append(pair)
# Return show_output to its previous value
self.show_output = prev_show_output
# We need to remove pairs that are unknown
return sanitized_whitelist