mirror of
https://github.com/kdave/btrfs-progs
synced 2025-05-16 23:08:38 +00:00
btrfs-progs: add helper to print messages to stderr
Add similar helper to pr_verbose that prints on stderr, for commands that need to print to stderr based on the set verbosity level. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
964a6377e7
commit
c780ab6611
@ -151,3 +151,21 @@ void error_msg(enum common_error error, const char *msg, ...)
|
||||
fprintf(stderr, PREFIX_ERROR "%s\n", str);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Print a message according to the global verbosity level - to stderr.
|
||||
*
|
||||
* level: minimum verbose level at which the message will be printed
|
||||
*/
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
void pr_stderr(int level, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (!should_print(level))
|
||||
return;
|
||||
|
||||
va_start(args, fmt);
|
||||
vfprintf(stderr, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
@ -130,6 +130,9 @@ void internal_error(const char *fmt, ...);
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
void pr_verbose(int level, const char *fmt, ...);
|
||||
|
||||
__attribute__ ((format (printf, 2, 3)))
|
||||
void pr_stderr(int level, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* Commonly used errors
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user