Detect color support on stderr, matching where logs are written

This commit is contained in:
LeoVasanko committed 2026-10-21 19:49:20 +00:00
1 parent 465206067b
commit a19c9028c5
1 file changed
+1 -2
+1 -2
View File
@@ -10,7 +10,6 @@ from __future__ import annotations
import io import io
import logging import logging
import sys
from contextlib import suppress from contextlib import suppress
from copy import deepcopy from copy import deepcopy
from typing import TYPE_CHECKING, Literal from typing import TYPE_CHECKING, Literal
@@ -92,7 +91,7 @@ class Formatter(logging.Formatter):
if use_colors in (True, False): if use_colors in (True, False):
self.use_colors = use_colors self.use_colors = use_colors
else: else:
self.use_colors = use_color(sys.stdout) self.use_colors = use_color()
super().__init__(fmt=fmt, datefmt=datefmt, style=style) super().__init__(fmt=fmt, datefmt=datefmt, style=style)
def formatMessage(self, record: logging.LogRecord) -> str: # noqa: N802 def formatMessage(self, record: logging.LogRecord) -> str: # noqa: N802