Skip to content

Commit

Permalink
perf tools: Factor eprintf to allow different debug variables
Browse files Browse the repository at this point in the history
This way we can easily reuse current debug functions for another debug
variables other than verbose.
Signed-off-by: Jiri Olsa <[email protected]>

Cc: Corey Ashford <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
olsajiri authored and acmel committed Jul 17, 2014
1 parent 84f5d36 commit c95688a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions tools/perf/util/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
int verbose;
bool dump_trace = false, quiet = false;

static int _eprintf(int level, const char *fmt, va_list args)
static int _eprintf(int level, int var, const char *fmt, va_list args)
{
int ret = 0;

if (verbose >= level) {
if (var >= level) {
if (use_browser >= 1)
ui_helpline__vshow(fmt, args);
else
Expand All @@ -30,13 +30,13 @@ static int _eprintf(int level, const char *fmt, va_list args)
return ret;
}

int eprintf(int level, const char *fmt, ...)
int eprintf(int level, int var, const char *fmt, ...)
{
va_list args;
int ret;

va_start(args, fmt);
ret = _eprintf(level, fmt, args);
ret = _eprintf(level, var, fmt, args);
va_end(args);

return ret;
Expand All @@ -51,9 +51,9 @@ void pr_stat(const char *fmt, ...)
va_list args;

va_start(args, fmt);
_eprintf(1, fmt, args);
_eprintf(1, verbose, fmt, args);
va_end(args);
eprintf(1, "\n");
eprintf(1, verbose, "\n");
}

int dump_printf(const char *fmt, ...)
Expand Down
12 changes: 6 additions & 6 deletions tools/perf/util/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ extern bool quiet, dump_trace;
#endif

#define pr_err(fmt, ...) \
eprintf(0, pr_fmt(fmt), ##__VA_ARGS__)
eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning(fmt, ...) \
eprintf(0, pr_fmt(fmt), ##__VA_ARGS__)
eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_info(fmt, ...) \
eprintf(0, pr_fmt(fmt), ##__VA_ARGS__)
eprintf(0, verbose, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debug(fmt, ...) \
eprintf(1, pr_fmt(fmt), ##__VA_ARGS__)
eprintf(1, verbose, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debugN(n, fmt, ...) \
eprintf(n, pr_fmt(fmt), ##__VA_ARGS__)
eprintf(n, verbose, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debug2(fmt, ...) pr_debugN(2, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debug3(fmt, ...) pr_debugN(3, pr_fmt(fmt), ##__VA_ARGS__)
#define pr_debug4(fmt, ...) pr_debugN(4, pr_fmt(fmt), ##__VA_ARGS__)
Expand All @@ -37,6 +37,6 @@ int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));

void pr_stat(const char *fmt, ...);

int eprintf(int level, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
int eprintf(int level, int var, const char *fmt, ...) __attribute__((format(printf, 3, 4)));

#endif /* __PERF_DEBUG_H */
4 changes: 2 additions & 2 deletions tools/perf/util/python.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/
int verbose;

int eprintf(int level, const char *fmt, ...)
int eprintf(int level, int var, const char *fmt, ...)
{
va_list args;
int ret = 0;

if (verbose >= level) {
if (var >= level) {
va_start(args, fmt);
ret = vfprintf(stderr, fmt, args);
va_end(args);
Expand Down

0 comments on commit c95688a

Please sign in to comment.