[IMP] Allow to force a colored output even if not in a tty enabled terminal

Check the PY_COLORS env variable and force colored output even if the
is_a_tty is no true

TT24972

closes odoo/odoo#71685

Signed-off-by: Olivier Dony <odo@odoo.com>
This commit is contained in:
João Marques
2022-06-02 12:04:51 +02:00
parent 652571a7fa
commit ba7cddb6fc
+1 -1
View File
@@ -188,7 +188,7 @@ def init_logger():
def is_a_tty(stream):
return hasattr(stream, 'fileno') and os.isatty(stream.fileno())
if os.name == 'posix' and isinstance(handler, logging.StreamHandler) and is_a_tty(handler.stream):
if os.name == 'posix' and isinstance(handler, logging.StreamHandler) and (is_a_tty(handler.stream) or os.environ.get("ODOO_PY_COLORS")):
formatter = ColoredFormatter(format)
perf_filter = ColoredPerfFilter()
else: