aboutsummaryrefslogtreecommitdiff
path: root/src/libeinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libeinfo.c')
-rw-r--r--src/libeinfo.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/libeinfo.c b/src/libeinfo.c
index a6c0a2a1..4b2f9589 100644
--- a/src/libeinfo.c
+++ b/src/libeinfo.c
@@ -125,6 +125,9 @@ static int stdfd[2] = {-1, -1};
static FILE *ebfp = NULL;
static char ebfile[PATH_MAX] = { '\0' };
+/* A pointer to a string to prefix to einfo/ewarn/eerror messages */
+static const char *_eprefix = NULL;
+
static bool is_env (const char *var, const char *val)
{
char *v;
@@ -184,6 +187,10 @@ static int get_term_columns (void)
return (DEFAULT_COLS);
}
+void eprefix (const char *prefix) {
+ _eprefix = prefix;
+}
+
void ebuffer (const char *file)
{
/* Don't ebuffer if we don't have a file or we already are */
@@ -379,16 +386,18 @@ const char *ecolor (einfo_color_t color) {
hidden_def(ecolor)
#define EINFOVN(_file, _color) \
-fprintf (_file, " %s*%s ", ecolor (_color), ecolor (ecolor_normal)); \
-retval += _eindent (_file); \
+ if (_eprefix) \
+ fprintf (_file, "%s%s%s|", ecolor (_color), _eprefix, ecolor (ecolor_normal)); \
+ fprintf (_file, " %s*%s ", ecolor (_color), ecolor (ecolor_normal)); \
+ retval += _eindent (_file); \
{ \
va_list _ap; \
va_copy (_ap, ap); \
retval += vfprintf (_file, fmt, _ap) + 3; \
va_end (_ap); \
} \
-if (colour_terminal ()) \
-fprintf (_file, ECOLOR_FLUSH);
+ if (colour_terminal ()) \
+ fprintf (_file, ECOLOR_FLUSH);
static int _einfovn (const char *fmt, va_list ap)
{