This is an automated email from the ASF dual-hosted git repository. potiuk pushed a commit to branch v1-10-test in repository https://gitbox.apache.org/repos/asf/airflow.git
commit 879b95f7a74146b5f79df6d2a0a5b9df639ce32f Author: Ash Berlin-Taylor <[email protected]> AuthorDate: Thu Jun 11 11:50:33 2020 +0100 Correctly restore colour in logs after format arg (#9222) The "\e[22m" escape sequence has been tested on Konsole, iTerm2 and Terminal.app (cherry picked from commit bfe1d6b1aafc757f821ceb077e6b882ff1363357) --- airflow/utils/log/colored_log.py | 13 ++++++++----- setup.py | 1 - 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/airflow/utils/log/colored_log.py b/airflow/utils/log/colored_log.py index a89e779..8f92d80 100644 --- a/airflow/utils/log/colored_log.py +++ b/airflow/utils/log/colored_log.py @@ -23,9 +23,7 @@ import re import sys from colorlog import TTYColoredFormatter -from termcolor import colored - -ARGS = {"attrs": ["bold"]} +from colorlog.escape_codes import esc, escape_codes DEFAULT_COLORS = { "DEBUG": "red", @@ -35,6 +33,9 @@ DEFAULT_COLORS = { "CRITICAL": "red", } +BOLD_ON = escape_codes['bold'] +BOLD_OFF = esc('22') + class CustomTTYColoredFormatter(TTYColoredFormatter): """ @@ -52,7 +53,7 @@ class CustomTTYColoredFormatter(TTYColoredFormatter): if isinstance(arg, (int, float)): # In case of %d or %f formatting return arg - return colored(str(arg), **ARGS) # type: ignore + return BOLD_ON + str(arg) + BOLD_OFF @staticmethod def _count_number_of_arguments_in_message(record): @@ -83,7 +84,9 @@ class CustomTTYColoredFormatter(TTYColoredFormatter): record.exc_text = self.formatException(record.exc_info) if record.exc_text: - record.exc_text = colored(record.exc_text, DEFAULT_COLORS["ERROR"]) + record.exc_text = self.color(self.log_colors, record.levelname) + \ + record.exc_text + escape_codes['reset'] + return record def format(self, record): diff --git a/setup.py b/setup.py index 9f05da9..61339e7 100644 --- a/setup.py +++ b/setup.py @@ -586,7 +586,6 @@ INSTALL_REQUIREMENTS = [ 'sqlalchemy_jsonfield~=0.9;python_version>="3.5"', 'tabulate>=0.7.5, <0.9', 'tenacity==4.12.0', - 'termcolor==1.1.0', 'thrift>=0.9.2', 'typing;python_version<"3.5"', 'typing-extensions>=3.7.4;python_version<"3.8"',
