From 6775e3729aec34691ec0199eb00a27a6a61e2908 Mon Sep 17 00:00:00 2001 From: Vaqxai Date: Mon, 21 Oct 2024 10:28:51 +0200 Subject: [PATCH 1/2] Remove ANSI character stripping from STDOUT upon colorama init - Until now ANSI was stripped from stdout if bittensor was not running within a TTY (like in PM2) - This caused colored output to be broken under PM2 (and other process managers which do not give a TTY do bittensor/python - Bittensor posseses its own file logger, which makes this behavior unnecessary and unwanted. - This patch disables that behavior. --- bittensor/utils/btlogging/format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/utils/btlogging/format.py b/bittensor/utils/btlogging/format.py index 1aa505c82c..1ca4bce6de 100644 --- a/bittensor/utils/btlogging/format.py +++ b/bittensor/utils/btlogging/format.py @@ -26,7 +26,7 @@ from typing import Optional from colorama import init, Fore, Back, Style -init(autoreset=True) +init(autoreset=True, strip=False) TRACE_LEVEL_NUM: int = 5 SUCCESS_LEVEL_NUM: int = 21 From 028b09a30a4aa529ca0cdae8119161ecec7b8e69 Mon Sep 17 00:00:00 2001 From: Vaqxai Date: Mon, 21 Oct 2024 11:40:48 +0200 Subject: [PATCH 2/2] Change colorama init to not wrap output Only without output wrapping does terminal output under PM2 behave correctly. --- bittensor/utils/btlogging/format.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bittensor/utils/btlogging/format.py b/bittensor/utils/btlogging/format.py index 1ca4bce6de..fc196cda6a 100644 --- a/bittensor/utils/btlogging/format.py +++ b/bittensor/utils/btlogging/format.py @@ -26,7 +26,7 @@ from typing import Optional from colorama import init, Fore, Back, Style -init(autoreset=True, strip=False) +init(wrap=False) TRACE_LEVEL_NUM: int = 5 SUCCESS_LEVEL_NUM: int = 21