From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 47C18158017 for ; Tue, 28 Sep 2021 14:20:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D2616E08C8; Tue, 28 Sep 2021 14:20:11 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A898BE08C8 for ; Tue, 28 Sep 2021 14:20:11 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-portage-dev] [PATCH 2/4] Use distinct colors for output msg types Date: Tue, 28 Sep 2021 16:20:02 +0200 Message-Id: <20210928142004.1375262-3-mgorny@gentoo.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210928142004.1375262-1-mgorny@gentoo.org> References: <20210928142004.1375262-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: a1c9c386-4d23-4919-88c0-26ccb3319f2e X-Archives-Hash: b72612be909dadd9c8d733a56b96e2a6 Introduce distinct colors per output function. For elog and eerror the colors remain the same but the names change. For einfo and eqawarn, use darker colors to distinguish them. Signed-off-by: Michał Górny --- bin/isolated-functions.sh | 30 +++++++++++------- bin/save-ebuild-env.sh | 6 ++-- lib/portage/elog/messages.py | 10 +++--- lib/portage/elog/mod_echo.py | 4 +-- lib/portage/output.py | 59 +++++++++++++++++++++++++++++++----- 5 files changed, 81 insertions(+), 28 deletions(-) diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 3e79ea6e3..df806d403 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -270,7 +270,7 @@ eqawarn() { __elog_base QA "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 + echo " ${PORTAGE_COLOR_QAWARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 done LAST_E_CMD="eqawarn" return 0 @@ -280,7 +280,7 @@ elog() { __elog_base LOG "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 + echo " ${PORTAGE_COLOR_LOG}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 done LAST_E_CMD="elog" return 0 @@ -290,7 +290,7 @@ einfo() { __elog_base INFO "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 + echo " ${PORTAGE_COLOR_INFO}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 done LAST_E_CMD="einfo" return 0 @@ -299,7 +299,7 @@ einfo() { einfon() { __elog_base INFO "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 - echo -ne " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} $*" >&2 + echo -ne " ${PORTAGE_COLOR_INFO}*${PORTAGE_COLOR_NORMAL} $*" >&2 LAST_E_CMD="einfon" return 0 } @@ -318,7 +318,7 @@ eerror() { __elog_base ERROR "$*" [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 echo -e "$@" | while read -r ; do - echo " ${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 + echo " ${PORTAGE_COLOR_ERR}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 done LAST_E_CMD="eerror" return 0 @@ -378,12 +378,16 @@ __unset_colors() { COLS=80 ENDCOL= - PORTAGE_COLOR_GOOD= - PORTAGE_COLOR_WARN= PORTAGE_COLOR_BAD= + PORTAGE_COLOR_BRACKET= + PORTAGE_COLOR_ERR= + PORTAGE_COLOR_GOOD= PORTAGE_COLOR_HILITE= + PORTAGE_COLOR_INFO= + PORTAGE_COLOR_LOG= PORTAGE_COLOR_NORMAL= - PORTAGE_COLOR_BRACKET= + PORTAGE_COLOR_QAWARN= + PORTAGE_COLOR_WARN= } __set_colors() { @@ -403,12 +407,16 @@ __set_colors() { if [ -n "${PORTAGE_COLORMAP}" ] ; then eval ${PORTAGE_COLORMAP} else - PORTAGE_COLOR_GOOD=$'\e[32;01m' - PORTAGE_COLOR_WARN=$'\e[33;01m' PORTAGE_COLOR_BAD=$'\e[31;01m' - PORTAGE_COLOR_HILITE=$'\e[36;01m' PORTAGE_COLOR_BRACKET=$'\e[34;01m' + PORTAGE_COLOR_ERR=$'\e[31;01m' + PORTAGE_COLOR_GOOD=$'\e[32;01m' + PORTAGE_COLOR_HILITE=$'\e[36;01m' + PORTAGE_COLOR_INFO=$'\e[32m' + PORTAGE_COLOR_LOG=$'\e[32;01m' PORTAGE_COLOR_NORMAL=$'\e[0m' + PORTAGE_COLOR_QAWARN=$'\e[33m' + PORTAGE_COLOR_WARN=$'\e[33;01m' fi } diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh index 8d2ec67ed..98808814b 100644 --- a/bin/save-ebuild-env.sh +++ b/bin/save-ebuild-env.sh @@ -102,8 +102,10 @@ __save_ebuild_env() { LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \ NOCOLOR PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \ PORTAGE_BASHRC_FILES PORTAGE_BASHRCS_SOURCED \ - PORTAGE_COLOR_BAD PORTAGE_COLOR_BRACKET PORTAGE_COLOR_GOOD \ - PORTAGE_COLOR_HILITE PORTAGE_COLOR_NORMAL PORTAGE_COLOR_WARN \ + PORTAGE_COLOR_BAD PORTAGE_COLOR_BRACKET PORTAGE_COLOR_ERR \ + PORTAGE_COLOR_GOOD PORTAGE_COLOR_HILITE PORTAGE_COLOR_INFO \ + PORTAGE_COLOR_LOG PORTAGE_COLOR_NORMAL PORTAGE_COLOR_QAWARN \ + PORTAGE_COLOR_WARN \ PORTAGE_COMPRESS PORTAGE_COMPRESS_EXCLUDE_SUFFIXES \ PORTAGE_DOHTML_UNWARNED_SKIPPED_EXTENSIONS \ PORTAGE_DOHTML_UNWARNED_SKIPPED_FILES \ diff --git a/lib/portage/elog/messages.py b/lib/portage/elog/messages.py index 923e10b69..6a67a45de 100644 --- a/lib/portage/elog/messages.py +++ b/lib/portage/elog/messages.py @@ -125,7 +125,7 @@ def _elog_base(level, msg, phase="other", key=None, color=None, out=None): out = sys.stdout if color is None: - color = "GOOD" + color = "INFO" msg = _unicode_decode(msg, encoding=_encodings["content"], errors="replace") @@ -183,11 +183,11 @@ def _reset_buffer(): # creating and exporting the actual messaging functions _functions = { - "einfo": ("INFO", "GOOD"), - "elog": ("LOG", "GOOD"), + "einfo": ("INFO", "INFO"), + "elog": ("LOG", "LOG"), "ewarn": ("WARN", "WARN"), - "eqawarn": ("QA", "WARN"), - "eerror": ("ERROR", "BAD"), + "eqawarn": ("QA", "QAWARN"), + "eerror": ("ERROR", "ERR"), } diff --git a/lib/portage/elog/mod_echo.py b/lib/portage/elog/mod_echo.py index fa9203c32..a63939988 100644 --- a/lib/portage/elog/mod_echo.py +++ b/lib/portage/elog/mod_echo.py @@ -60,10 +60,10 @@ def _finalize(): for msgtype, msgcontent in logentries[phase]: fmap = { "INFO": printer.einfo, + "LOG": printer.elog, "WARN": printer.ewarn, "ERROR": printer.eerror, - "LOG": printer.einfo, - "QA": printer.ewarn, + "QA": printer.eqawarn, } if isinstance(msgcontent, str): msgcontent = [msgcontent] diff --git a/lib/portage/output.py b/lib/portage/output.py index 9d8601b24..42f487f8a 100644 --- a/lib/portage/output.py +++ b/lib/portage/output.py @@ -140,12 +140,16 @@ codes["darkyellow"] = codes["0xAAAA00"] # Colors from /etc/init.d/functions.sh -_styles["NORMAL"] = ("normal",) -_styles["GOOD"] = ("green",) -_styles["WARN"] = ("yellow",) _styles["BAD"] = ("red",) -_styles["HILITE"] = ("teal",) _styles["BRACKET"] = ("blue",) +_styles["ERR"] = ("red",) +_styles["GOOD"] = ("green",) +_styles["HILITE"] = ("teal",) +_styles["INFO"] = ("darkgreen",) +_styles["LOG"] = ("green",) +_styles["NORMAL"] = ("normal",) +_styles["QAWARN"] = ("brown",) +_styles["WARN"] = ("yellow",) # Portage functions _styles["INFORM"] = ("darkgreen",) @@ -377,7 +381,18 @@ def style_to_ansi_code(style): def colormap(): mycolors = [] - for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET", "NORMAL"): + for c in ( + "BAD", + "BRACKET", + "ERR", + "GOOD", + "HILITE", + "INFO", + "LOG", + "NORMAL", + "QAWARN", + "WARN", + ): mycolors.append("PORTAGE_COLOR_{}=$'{}'".format(c, style_to_ansi_code(c))) return "\n".join(mycolors) @@ -665,7 +680,7 @@ class EOutput: if not self.quiet: if self.__last_e_cmd == "ebegin": self._write(out, "\n") - self._write(out, colorize("BAD", " * ") + msg + "\n") + self._write(out, colorize("ERR", " * ") + msg + "\n") self.__last_e_cmd = "eerror" def einfo(self, msg): @@ -679,7 +694,7 @@ class EOutput: if not self.quiet: if self.__last_e_cmd == "ebegin": self._write(out, "\n") - self._write(out, colorize("GOOD", " * ") + msg + "\n") + self._write(out, colorize("INFO", " * ") + msg + "\n") self.__last_e_cmd = "einfo" def einfon(self, msg): @@ -693,9 +708,37 @@ class EOutput: if not self.quiet: if self.__last_e_cmd == "ebegin": self._write(out, "\n") - self._write(out, colorize("GOOD", " * ") + msg) + self._write(out, colorize("INFO", " * ") + msg) self.__last_e_cmd = "einfon" + def eqawarn(self, msg): + """ + Shows a QA warning. + + @param msg: A very brief (shorter than one line) warning message. + @type msg: StringType + """ + out = sys.stderr + if not self.quiet: + if self.__last_e_cmd == "ebegin": + self._write(out, "\n") + self._write(out, colorize("QAWARN", " * ") + msg + "\n") + self.__last_e_cmd = "ewarn" + + def elog(self, msg): + """ + Shows a logged informative message terminated with a newline. + + @param msg: A very brief (shorter than one line) informative message. + @type msg: StringType + """ + out = sys.stdout + if not self.quiet: + if self.__last_e_cmd == "ebegin": + self._write(out, "\n") + self._write(out, colorize("LOG", " * ") + msg + "\n") + self.__last_e_cmd = "elog" + def ewarn(self, msg): """ Shows a warning message. -- 2.33.0