1 |
commit: 3ab738a7a5a81ee3d5b973e93a4d93f6e497a321 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 28 12:50:52 2021 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Oct 4 07:27:46 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=3ab738a7 |
7 |
|
8 |
Use distinct colors for output msg types |
9 |
|
10 |
Introduce distinct colors per output function. For elog and eerror |
11 |
the colors remain the same but the names change. For einfo and eqawarn, |
12 |
use darker colors to distinguish them. |
13 |
|
14 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
15 |
|
16 |
bin/isolated-functions.sh | 30 +++++++++++++--------- |
17 |
bin/save-ebuild-env.sh | 6 +++-- |
18 |
lib/portage/elog/messages.py | 10 ++++---- |
19 |
lib/portage/elog/mod_echo.py | 4 +-- |
20 |
lib/portage/output.py | 59 ++++++++++++++++++++++++++++++++++++++------ |
21 |
5 files changed, 81 insertions(+), 28 deletions(-) |
22 |
|
23 |
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh |
24 |
index 3e79ea6e3..df806d403 100644 |
25 |
--- a/bin/isolated-functions.sh |
26 |
+++ b/bin/isolated-functions.sh |
27 |
@@ -270,7 +270,7 @@ eqawarn() { |
28 |
__elog_base QA "$*" |
29 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
30 |
echo -e "$@" | while read -r ; do |
31 |
- echo " ${PORTAGE_COLOR_WARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
32 |
+ echo " ${PORTAGE_COLOR_QAWARN}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
33 |
done |
34 |
LAST_E_CMD="eqawarn" |
35 |
return 0 |
36 |
@@ -280,7 +280,7 @@ elog() { |
37 |
__elog_base LOG "$*" |
38 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
39 |
echo -e "$@" | while read -r ; do |
40 |
- echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
41 |
+ echo " ${PORTAGE_COLOR_LOG}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
42 |
done |
43 |
LAST_E_CMD="elog" |
44 |
return 0 |
45 |
@@ -290,7 +290,7 @@ einfo() { |
46 |
__elog_base INFO "$*" |
47 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
48 |
echo -e "$@" | while read -r ; do |
49 |
- echo " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
50 |
+ echo " ${PORTAGE_COLOR_INFO}*${PORTAGE_COLOR_NORMAL} ${REPLY}" >&2 |
51 |
done |
52 |
LAST_E_CMD="einfo" |
53 |
return 0 |
54 |
@@ -299,7 +299,7 @@ einfo() { |
55 |
einfon() { |
56 |
__elog_base INFO "$*" |
57 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
58 |
- echo -ne " ${PORTAGE_COLOR_GOOD}*${PORTAGE_COLOR_NORMAL} $*" >&2 |
59 |
+ echo -ne " ${PORTAGE_COLOR_INFO}*${PORTAGE_COLOR_NORMAL} $*" >&2 |
60 |
LAST_E_CMD="einfon" |
61 |
return 0 |
62 |
} |
63 |
@@ -318,7 +318,7 @@ eerror() { |
64 |
__elog_base ERROR "$*" |
65 |
[[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo >&2 |
66 |
echo -e "$@" | while read -r ; do |
67 |
- echo " ${PORTAGE_COLOR_BAD}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 |
68 |
+ echo " ${PORTAGE_COLOR_ERR}*${PORTAGE_COLOR_NORMAL} ${RC_INDENTATION}${REPLY}" >&2 |
69 |
done |
70 |
LAST_E_CMD="eerror" |
71 |
return 0 |
72 |
@@ -378,12 +378,16 @@ __unset_colors() { |
73 |
COLS=80 |
74 |
ENDCOL= |
75 |
|
76 |
- PORTAGE_COLOR_GOOD= |
77 |
- PORTAGE_COLOR_WARN= |
78 |
PORTAGE_COLOR_BAD= |
79 |
+ PORTAGE_COLOR_BRACKET= |
80 |
+ PORTAGE_COLOR_ERR= |
81 |
+ PORTAGE_COLOR_GOOD= |
82 |
PORTAGE_COLOR_HILITE= |
83 |
+ PORTAGE_COLOR_INFO= |
84 |
+ PORTAGE_COLOR_LOG= |
85 |
PORTAGE_COLOR_NORMAL= |
86 |
- PORTAGE_COLOR_BRACKET= |
87 |
+ PORTAGE_COLOR_QAWARN= |
88 |
+ PORTAGE_COLOR_WARN= |
89 |
} |
90 |
|
91 |
__set_colors() { |
92 |
@@ -403,12 +407,16 @@ __set_colors() { |
93 |
if [ -n "${PORTAGE_COLORMAP}" ] ; then |
94 |
eval ${PORTAGE_COLORMAP} |
95 |
else |
96 |
- PORTAGE_COLOR_GOOD=$'\e[32;01m' |
97 |
- PORTAGE_COLOR_WARN=$'\e[33;01m' |
98 |
PORTAGE_COLOR_BAD=$'\e[31;01m' |
99 |
- PORTAGE_COLOR_HILITE=$'\e[36;01m' |
100 |
PORTAGE_COLOR_BRACKET=$'\e[34;01m' |
101 |
+ PORTAGE_COLOR_ERR=$'\e[31;01m' |
102 |
+ PORTAGE_COLOR_GOOD=$'\e[32;01m' |
103 |
+ PORTAGE_COLOR_HILITE=$'\e[36;01m' |
104 |
+ PORTAGE_COLOR_INFO=$'\e[32m' |
105 |
+ PORTAGE_COLOR_LOG=$'\e[32;01m' |
106 |
PORTAGE_COLOR_NORMAL=$'\e[0m' |
107 |
+ PORTAGE_COLOR_QAWARN=$'\e[33m' |
108 |
+ PORTAGE_COLOR_WARN=$'\e[33;01m' |
109 |
fi |
110 |
} |
111 |
|
112 |
|
113 |
diff --git a/bin/save-ebuild-env.sh b/bin/save-ebuild-env.sh |
114 |
index 8d2ec67ed..98808814b 100644 |
115 |
--- a/bin/save-ebuild-env.sh |
116 |
+++ b/bin/save-ebuild-env.sh |
117 |
@@ -102,8 +102,10 @@ __save_ebuild_env() { |
118 |
LAST_E_CMD LAST_E_LEN LD_PRELOAD MISC_FUNCTIONS_ARGS MOPREFIX \ |
119 |
NOCOLOR PKGDIR PKGUSE PKG_LOGDIR PKG_TMPDIR \ |
120 |
PORTAGE_BASHRC_FILES PORTAGE_BASHRCS_SOURCED \ |
121 |
- PORTAGE_COLOR_BAD PORTAGE_COLOR_BRACKET PORTAGE_COLOR_GOOD \ |
122 |
- PORTAGE_COLOR_HILITE PORTAGE_COLOR_NORMAL PORTAGE_COLOR_WARN \ |
123 |
+ PORTAGE_COLOR_BAD PORTAGE_COLOR_BRACKET PORTAGE_COLOR_ERR \ |
124 |
+ PORTAGE_COLOR_GOOD PORTAGE_COLOR_HILITE PORTAGE_COLOR_INFO \ |
125 |
+ PORTAGE_COLOR_LOG PORTAGE_COLOR_NORMAL PORTAGE_COLOR_QAWARN \ |
126 |
+ PORTAGE_COLOR_WARN \ |
127 |
PORTAGE_COMPRESS PORTAGE_COMPRESS_EXCLUDE_SUFFIXES \ |
128 |
PORTAGE_DOHTML_UNWARNED_SKIPPED_EXTENSIONS \ |
129 |
PORTAGE_DOHTML_UNWARNED_SKIPPED_FILES \ |
130 |
|
131 |
diff --git a/lib/portage/elog/messages.py b/lib/portage/elog/messages.py |
132 |
index 923e10b69..6a67a45de 100644 |
133 |
--- a/lib/portage/elog/messages.py |
134 |
+++ b/lib/portage/elog/messages.py |
135 |
@@ -125,7 +125,7 @@ def _elog_base(level, msg, phase="other", key=None, color=None, out=None): |
136 |
out = sys.stdout |
137 |
|
138 |
if color is None: |
139 |
- color = "GOOD" |
140 |
+ color = "INFO" |
141 |
|
142 |
msg = _unicode_decode(msg, encoding=_encodings["content"], errors="replace") |
143 |
|
144 |
@@ -183,11 +183,11 @@ def _reset_buffer(): |
145 |
|
146 |
# creating and exporting the actual messaging functions |
147 |
_functions = { |
148 |
- "einfo": ("INFO", "GOOD"), |
149 |
- "elog": ("LOG", "GOOD"), |
150 |
+ "einfo": ("INFO", "INFO"), |
151 |
+ "elog": ("LOG", "LOG"), |
152 |
"ewarn": ("WARN", "WARN"), |
153 |
- "eqawarn": ("QA", "WARN"), |
154 |
- "eerror": ("ERROR", "BAD"), |
155 |
+ "eqawarn": ("QA", "QAWARN"), |
156 |
+ "eerror": ("ERROR", "ERR"), |
157 |
} |
158 |
|
159 |
|
160 |
|
161 |
diff --git a/lib/portage/elog/mod_echo.py b/lib/portage/elog/mod_echo.py |
162 |
index fa9203c32..a63939988 100644 |
163 |
--- a/lib/portage/elog/mod_echo.py |
164 |
+++ b/lib/portage/elog/mod_echo.py |
165 |
@@ -60,10 +60,10 @@ def _finalize(): |
166 |
for msgtype, msgcontent in logentries[phase]: |
167 |
fmap = { |
168 |
"INFO": printer.einfo, |
169 |
+ "LOG": printer.elog, |
170 |
"WARN": printer.ewarn, |
171 |
"ERROR": printer.eerror, |
172 |
- "LOG": printer.einfo, |
173 |
- "QA": printer.ewarn, |
174 |
+ "QA": printer.eqawarn, |
175 |
} |
176 |
if isinstance(msgcontent, str): |
177 |
msgcontent = [msgcontent] |
178 |
|
179 |
diff --git a/lib/portage/output.py b/lib/portage/output.py |
180 |
index 9d8601b24..42f487f8a 100644 |
181 |
--- a/lib/portage/output.py |
182 |
+++ b/lib/portage/output.py |
183 |
@@ -140,12 +140,16 @@ codes["darkyellow"] = codes["0xAAAA00"] |
184 |
|
185 |
|
186 |
# Colors from /etc/init.d/functions.sh |
187 |
-_styles["NORMAL"] = ("normal",) |
188 |
-_styles["GOOD"] = ("green",) |
189 |
-_styles["WARN"] = ("yellow",) |
190 |
_styles["BAD"] = ("red",) |
191 |
-_styles["HILITE"] = ("teal",) |
192 |
_styles["BRACKET"] = ("blue",) |
193 |
+_styles["ERR"] = ("red",) |
194 |
+_styles["GOOD"] = ("green",) |
195 |
+_styles["HILITE"] = ("teal",) |
196 |
+_styles["INFO"] = ("darkgreen",) |
197 |
+_styles["LOG"] = ("green",) |
198 |
+_styles["NORMAL"] = ("normal",) |
199 |
+_styles["QAWARN"] = ("brown",) |
200 |
+_styles["WARN"] = ("yellow",) |
201 |
|
202 |
# Portage functions |
203 |
_styles["INFORM"] = ("darkgreen",) |
204 |
@@ -377,7 +381,18 @@ def style_to_ansi_code(style): |
205 |
|
206 |
def colormap(): |
207 |
mycolors = [] |
208 |
- for c in ("GOOD", "WARN", "BAD", "HILITE", "BRACKET", "NORMAL"): |
209 |
+ for c in ( |
210 |
+ "BAD", |
211 |
+ "BRACKET", |
212 |
+ "ERR", |
213 |
+ "GOOD", |
214 |
+ "HILITE", |
215 |
+ "INFO", |
216 |
+ "LOG", |
217 |
+ "NORMAL", |
218 |
+ "QAWARN", |
219 |
+ "WARN", |
220 |
+ ): |
221 |
mycolors.append("PORTAGE_COLOR_{}=$'{}'".format(c, style_to_ansi_code(c))) |
222 |
return "\n".join(mycolors) |
223 |
|
224 |
@@ -665,7 +680,7 @@ class EOutput: |
225 |
if not self.quiet: |
226 |
if self.__last_e_cmd == "ebegin": |
227 |
self._write(out, "\n") |
228 |
- self._write(out, colorize("BAD", " * ") + msg + "\n") |
229 |
+ self._write(out, colorize("ERR", " * ") + msg + "\n") |
230 |
self.__last_e_cmd = "eerror" |
231 |
|
232 |
def einfo(self, msg): |
233 |
@@ -679,7 +694,7 @@ class EOutput: |
234 |
if not self.quiet: |
235 |
if self.__last_e_cmd == "ebegin": |
236 |
self._write(out, "\n") |
237 |
- self._write(out, colorize("GOOD", " * ") + msg + "\n") |
238 |
+ self._write(out, colorize("INFO", " * ") + msg + "\n") |
239 |
self.__last_e_cmd = "einfo" |
240 |
|
241 |
def einfon(self, msg): |
242 |
@@ -693,9 +708,37 @@ class EOutput: |
243 |
if not self.quiet: |
244 |
if self.__last_e_cmd == "ebegin": |
245 |
self._write(out, "\n") |
246 |
- self._write(out, colorize("GOOD", " * ") + msg) |
247 |
+ self._write(out, colorize("INFO", " * ") + msg) |
248 |
self.__last_e_cmd = "einfon" |
249 |
|
250 |
+ def eqawarn(self, msg): |
251 |
+ """ |
252 |
+ Shows a QA warning. |
253 |
+ |
254 |
+ @param msg: A very brief (shorter than one line) warning message. |
255 |
+ @type msg: StringType |
256 |
+ """ |
257 |
+ out = sys.stderr |
258 |
+ if not self.quiet: |
259 |
+ if self.__last_e_cmd == "ebegin": |
260 |
+ self._write(out, "\n") |
261 |
+ self._write(out, colorize("QAWARN", " * ") + msg + "\n") |
262 |
+ self.__last_e_cmd = "ewarn" |
263 |
+ |
264 |
+ def elog(self, msg): |
265 |
+ """ |
266 |
+ Shows a logged informative message terminated with a newline. |
267 |
+ |
268 |
+ @param msg: A very brief (shorter than one line) informative message. |
269 |
+ @type msg: StringType |
270 |
+ """ |
271 |
+ out = sys.stdout |
272 |
+ if not self.quiet: |
273 |
+ if self.__last_e_cmd == "ebegin": |
274 |
+ self._write(out, "\n") |
275 |
+ self._write(out, colorize("LOG", " * ") + msg + "\n") |
276 |
+ self.__last_e_cmd = "elog" |
277 |
+ |
278 |
def ewarn(self, msg): |
279 |
""" |
280 |
Shows a warning message. |