From 709b3bb4c07dc20956bce1fea1c13a9c07ad9119 Mon Sep 17 00:00:00 2001 From: xuhj Date: Sun, 25 Jan 2026 20:44:48 +0800 Subject: [PATCH] =?UTF-8?q?lbkit:=20=E6=97=A5=E5=BF=97=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E5=88=B0=E7=BB=88=E7=AB=AF=E6=97=B6=E8=BE=93=E5=87=BA=E9=A2=9C?= =?UTF-8?q?=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lbkit/lbkit/log.py | 6 +++--- lbkit/lbkit/tools.py | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lbkit/lbkit/log.py b/lbkit/lbkit/log.py index e4d48e2..0c032da 100644 --- a/lbkit/lbkit/log.py +++ b/lbkit/lbkit/log.py @@ -39,7 +39,7 @@ class Logger: retention="30 days", compression="zip", level="DEBUG", - colorize=None + colorize=False ) Logger._lock = False @@ -75,7 +75,7 @@ class Logger: format=format_str, level=level, filter=lambda record: record["level"].no < 40 and "tofile" not in record["extra"], # < ERROR level - colorize=None + colorize=True ) # Add handler for error messages (stderr) @@ -84,7 +84,7 @@ class Logger: format=format_str, level="ERROR", filter= lambda record: "tofile" not in record["extra"], - colorize=None + colorize=True ) Logger._configured = True Logger._lock = False diff --git a/lbkit/lbkit/tools.py b/lbkit/lbkit/tools.py index ab04c82..1170c88 100644 --- a/lbkit/lbkit/tools.py +++ b/lbkit/lbkit/tools.py @@ -151,7 +151,10 @@ class Tools(object): else: tee.write(show_cmd, True, False) real_cmd = self._real_command(cmd) - result = subprocess.Popen(real_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, text=True) + env = os.environ.copy() + env["FORCE_COLOR"] = "1" + env["CLICOLOR_FORCE"] = "1" + result = subprocess.Popen(real_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True, text=True, env=env) if result is None: raise errors.RunCommandException(f"Run command {show_cmd} failed") stdout_t = threading.Thread(target=tee.pipe_to_logger, args=(result.stdout, True)) -- Gitee