btrfs-progs: factor out check for message level
Factor out the level check so we can add helper for stderr as some commands don't/can't print to stdout. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b0fcdb9224
commit
964a6377e7
|
@ -102,6 +102,19 @@ void internal_error(const char *fmt, ...)
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool should_print(int level)
|
||||
{
|
||||
if (bconf.verbose == BTRFS_BCONF_QUIET || level == BTRFS_BCONF_QUIET)
|
||||
return false;
|
||||
|
||||
if (bconf.verbose == BTRFS_BCONF_UNSET && level == LOG_DEFAULT)
|
||||
return true;
|
||||
if (bconf.verbose < level)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a message according to the global verbosity level.
|
||||
*
|
||||
|
@ -112,12 +125,7 @@ void pr_verbose(int level, const char *fmt, ...)
|
|||
{
|
||||
va_list args;
|
||||
|
||||
if (bconf.verbose == BTRFS_BCONF_QUIET || level == BTRFS_BCONF_QUIET)
|
||||
return;
|
||||
|
||||
if (bconf.verbose == BTRFS_BCONF_UNSET && level == LOG_DEFAULT)
|
||||
/* Pass */;
|
||||
else if (bconf.verbose < level)
|
||||
if (!should_print(level))
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
|
|
Loading…
Reference in New Issue