libeinfo: add separate variable to suppress eerror messages

Add an EERROR_QUIET environment variable which works like EINFO_QUIET
but for the eerror functions. This will allow library consumers to
choose whether to suppress eerror messages separately from einfo and
ewarn messages.

X-Gentoo-Bug: 482396
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=482396
This commit is contained in:
William Hubbs 2013-09-01 15:06:15 -05:00
parent 4ce3cb90a0
commit 2590bf7a2b
2 changed files with 15 additions and 4 deletions

View File

@ -107,7 +107,6 @@ respectively, but only work when
is true. You can also make the is true. You can also make the
.Fn einfo , .Fn einfo ,
.Fn ewarn , .Fn ewarn ,
.Fn eerror ,
and and
.Fn ebegin .Fn ebegin
functions silent by setting functions silent by setting
@ -186,6 +185,12 @@ when set to true makes the
and and
.Fn einfon .Fn einfon
family of functions quiet, so nothing is printed. family of functions quiet, so nothing is printed.
.Va EERROR_QUIET
when set to true makes the
.Fn eerror
and
.Fn eerrorn
family of functions quiet, so nothing is printed.
.Pp .Pp
.Va EINFO_VERBOSE .Va EINFO_VERBOSE
when set to true makes the when set to true makes the

View File

@ -273,6 +273,12 @@ is_quiet(void)
return yesno(getenv("EINFO_QUIET")); return yesno(getenv("EINFO_QUIET"));
} }
static bool
is_really_quiet(void)
{
return yesno(getenv("EERROR_QUIET"));
}
static bool static bool
is_verbose(void) is_verbose(void)
{ {
@ -674,7 +680,7 @@ eerrorn(const char *EINFO_RESTRICT fmt, ...)
int retval; int retval;
va_list ap; va_list ap;
if (!fmt || is_quiet()) if (!fmt || is_really_quiet())
return 0; return 0;
va_start(ap, fmt); va_start(ap, fmt);
retval = _eerrorvn(fmt, ap); retval = _eerrorvn(fmt, ap);
@ -742,7 +748,7 @@ eerror(const char *EINFO_RESTRICT fmt, ...)
int retval; int retval;
va_list ap; va_list ap;
if (!fmt || is_quiet()) if (!fmt || is_really_quiet())
return 0; return 0;
va_start(ap, fmt); va_start(ap, fmt);
elogv(LOG_ERR, fmt, ap); elogv(LOG_ERR, fmt, ap);
@ -759,7 +765,7 @@ eerrorx(const char *EINFO_RESTRICT fmt, ...)
{ {
va_list ap; va_list ap;
if (fmt && !is_quiet()) { if (fmt && !is_really_quiet()) {
va_start(ap, fmt); va_start(ap, fmt);
elogv(LOG_ERR, fmt, ap); elogv(LOG_ERR, fmt, ap);
_eerrorvn(fmt, ap); _eerrorvn(fmt, ap);