public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-portage-dev] [PATCH 3/4] Use verbose prefixes for output messages
Date: Tue, 28 Sep 2021 16:20:03 +0200	[thread overview]
Message-ID: <20210928142004.1375262-4-mgorny@gentoo.org> (raw)
In-Reply-To: <20210928142004.1375262-1-mgorny@gentoo.org>

Use verbose prefixes for output functions einfo, elog... in order to
make the message types distinguishable on non-color terminals,
and to enable the possibility of grepping them.  The prefixes are
roughly inspired by Xorg logs, and are:

- `[--]` for einfo (and ebegin)
- `[II]` for elog
- `[WW]` for ewarn
- `[QA]` for eqawarn
- `[EE]` for eerror

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 bin/isolated-functions.sh | 12 ++++++------
 lib/portage/output.py     | 12 ++++++------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
index df806d403..c7fda6784 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_QAWARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2
+		echo "${PORTAGE_COLOR_QAWARN}[QA]${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_LOG}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2
+		echo "${PORTAGE_COLOR_LOG}[II]${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_INFO}*${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_INFO}*${PORTAGE_COLOR_NORMAL} $*" >&2
+	echo -ne "${PORTAGE_COLOR_INFO}[--]${PORTAGE_COLOR_NORMAL} $*" >&2
 	LAST_E_CMD="einfon"
 	return 0
 }
@@ -308,7 +308,7 @@ ewarn() {
 	__elog_base WARN "$*"
 	[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2
 	echo -e "$@" | while read -r ; do
-		echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2
+		echo "${PORTAGE_COLOR_WARN}[WW]${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2
 	done
 	LAST_E_CMD="ewarn"
 	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_ERR}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2
+		echo "${PORTAGE_COLOR_ERR}[EE]${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2
 	done
 	LAST_E_CMD="eerror"
 	return 0
diff --git a/lib/portage/output.py b/lib/portage/output.py
index 42f487f8a..deae207fc 100644
--- a/lib/portage/output.py
+++ b/lib/portage/output.py
@@ -680,7 +680,7 @@ class EOutput:
         if not self.quiet:
             if self.__last_e_cmd == "ebegin":
                 self._write(out, "\n")
-            self._write(out, colorize("ERR", " * ") + msg + "\n")
+            self._write(out, colorize("ERR", "[EE] ") + msg + "\n")
         self.__last_e_cmd = "eerror"
 
     def einfo(self, msg):
@@ -694,7 +694,7 @@ class EOutput:
         if not self.quiet:
             if self.__last_e_cmd == "ebegin":
                 self._write(out, "\n")
-            self._write(out, colorize("INFO", " * ") + msg + "\n")
+            self._write(out, colorize("INFO", "[--] ") + msg + "\n")
         self.__last_e_cmd = "einfo"
 
     def einfon(self, msg):
@@ -708,7 +708,7 @@ class EOutput:
         if not self.quiet:
             if self.__last_e_cmd == "ebegin":
                 self._write(out, "\n")
-            self._write(out, colorize("INFO", " * ") + msg)
+            self._write(out, colorize("INFO", "[--] ") + msg)
         self.__last_e_cmd = "einfon"
 
     def eqawarn(self, msg):
@@ -722,7 +722,7 @@ class EOutput:
         if not self.quiet:
             if self.__last_e_cmd == "ebegin":
                 self._write(out, "\n")
-            self._write(out, colorize("QAWARN", " * ") + msg + "\n")
+            self._write(out, colorize("QAWARN", "[QA] ") + msg + "\n")
         self.__last_e_cmd = "ewarn"
 
     def elog(self, msg):
@@ -736,7 +736,7 @@ class EOutput:
         if not self.quiet:
             if self.__last_e_cmd == "ebegin":
                 self._write(out, "\n")
-            self._write(out, colorize("LOG", " * ") + msg + "\n")
+            self._write(out, colorize("LOG", "[II] ") + msg + "\n")
         self.__last_e_cmd = "elog"
 
     def ewarn(self, msg):
@@ -750,7 +750,7 @@ class EOutput:
         if not self.quiet:
             if self.__last_e_cmd == "ebegin":
                 self._write(out, "\n")
-            self._write(out, colorize("WARN", " * ") + msg + "\n")
+            self._write(out, colorize("WARN", "[WW] ") + msg + "\n")
         self.__last_e_cmd = "ewarn"
 
     def ewend(self, errno, *msg):
-- 
2.33.0



  parent reply	other threads:[~2021-09-28 14:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-28 14:20 [gentoo-portage-dev] [PATCH 0/4] Output rewrite for better clarify and greppability Michał Górny
2021-09-28 14:20 ` [gentoo-portage-dev] [PATCH 1/4] Prefix color vars with "PORTAGE_COLOR_" Michał Górny
2021-09-28 14:20 ` [gentoo-portage-dev] [PATCH 2/4] Use distinct colors for output msg types Michał Górny
2021-09-28 14:20 ` Michał Górny [this message]
2021-09-28 14:20 ` [gentoo-portage-dev] [PATCH 4/4] Use ">>>>" and "!!!!" for output prefixes Michał Górny
2021-09-28 15:28 ` [gentoo-portage-dev] [PATCH 0/4] Output rewrite for better clarify and greppability Mike Gilbert
2021-09-28 15:37   ` Michał Górny
2021-10-04  6:49 ` Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210928142004.1375262-4-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-portage-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox