[pacman-dev] [PATCH] Color output from pm_vfprintf

Allan McRae allan at archlinux.org
Wed Nov 20 21:57:39 EST 2013


This makes sure warning and error messages from _alpm_log are colored.
Fixes FS#35160.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 src/pacman/util.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 23eea98..05135d7 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1593,10 +1593,12 @@ int pm_vasprintf(char **string, alpm_loglevel_t level, const char *format, va_li
 	/* print a prefix to the message */
 	switch(level) {
 		case ALPM_LOG_ERROR:
-			pm_asprintf(string, _("error: %s"), msg);
+			pm_asprintf(string, "%s%s%s%s", config->colstr.err, _("error: "),
+								config->colstr.nocolor, msg);
 			break;
 		case ALPM_LOG_WARNING:
-			pm_asprintf(string, _("warning: %s"), msg);
+			pm_asprintf(string, "%s%s%s%s", config->colstr.warn, _("warning: "),
+								config->colstr.nocolor, msg);
 			break;
 		case ALPM_LOG_DEBUG:
 			pm_asprintf(string, "debug: %s", msg);
-- 
1.8.4.2



More information about the pacman-dev mailing list