2023-06-09 04:59:08 +00:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
2023-06-09 05:13:45 +00:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
2024-05-12 14:30:42 +00:00
|
|
|
def set_loggers(verbosity: int = 0, api_verbosity: str = "info") -> None:
|
2023-06-09 04:59:08 +00:00
|
|
|
"""
|
|
|
|
Set the logging level for third party libraries
|
2023-10-05 05:03:29 +00:00
|
|
|
:param verbosity: Verbosity level. amount of `-v` passed to the command line
|
2023-06-09 04:59:08 +00:00
|
|
|
:return: None
|
|
|
|
"""
|
2024-05-12 14:30:42 +00:00
|
|
|
for logger_name in ("requests", "urllib3", "httpcore"):
|
|
|
|
logging.getLogger(logger_name).setLevel(logging.INFO if verbosity <= 1 else logging.DEBUG)
|
|
|
|
logging.getLogger("ccxt.base.exchange").setLevel(
|
2023-06-09 04:59:08 +00:00
|
|
|
logging.INFO if verbosity <= 2 else logging.DEBUG
|
|
|
|
)
|
2024-05-12 14:30:42 +00:00
|
|
|
logging.getLogger("telegram").setLevel(logging.INFO)
|
|
|
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
2023-06-09 04:59:08 +00:00
|
|
|
|
2024-05-12 14:30:42 +00:00
|
|
|
logging.getLogger("werkzeug").setLevel(
|
|
|
|
logging.ERROR if api_verbosity == "error" else logging.INFO
|
2023-06-09 04:59:08 +00:00
|
|
|
)
|
2023-06-09 05:13:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
__BIAS_TESTER_LOGGERS = [
|
2024-05-12 14:30:42 +00:00
|
|
|
"freqtrade.resolvers",
|
|
|
|
"freqtrade.strategy.hyper",
|
|
|
|
"freqtrade.configuration.config_validation",
|
2023-06-09 05:13:45 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def reduce_verbosity_for_bias_tester() -> None:
|
|
|
|
"""
|
|
|
|
Reduce verbosity for bias tester.
|
|
|
|
It loads the same strategy several times, which would spam the log.
|
|
|
|
"""
|
|
|
|
logger.info("Reducing verbosity for bias tester.")
|
|
|
|
for logger_name in __BIAS_TESTER_LOGGERS:
|
|
|
|
logging.getLogger(logger_name).setLevel(logging.WARNING)
|
|
|
|
|
|
|
|
|
|
|
|
def restore_verbosity_for_bias_tester() -> None:
|
|
|
|
"""
|
|
|
|
Restore verbosity after bias tester.
|
|
|
|
"""
|
|
|
|
logger.info("Restoring log verbosity.")
|
2023-06-10 07:44:08 +00:00
|
|
|
log_level = logging.NOTSET
|
2023-06-09 05:13:45 +00:00
|
|
|
for logger_name in __BIAS_TESTER_LOGGERS:
|
|
|
|
logging.getLogger(logger_name).setLevel(log_level)
|