diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-02-15 22:13:43 -0500 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2022-02-19 16:34:32 -0500 |
commit | bb721a53211ab78c5b99560d77eaa760eeb34b80 (patch) | |
tree | 6b1cb98cf8a1fd793ebe619a29cdbf01cbe14d7d | |
parent | 743edccb47ec662c18d1793a11906d2bd46660c0 (diff) | |
download | libtraceevent-bb721a53211ab78c5b99560d77eaa760eeb34b80.tar.gz |
libtraceevent: Have logs only print to stderr on WARNING or higher
The tep logs should only print to stderr for WARNINGS and higher. Info
messages can go to stdout.
Also, only print perror on warnings or higher.
Link: https://lore.kernel.org/linux-trace-devel/20220216031345.984113-3-rostedt@goodmis.org
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | src/parse-utils.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/parse-utils.c b/src/parse-utils.c index 3f4918f..09059ed 100644 --- a/src/parse-utils.c +++ b/src/parse-utils.c @@ -67,13 +67,17 @@ int __tep_vprint(const char *name, enum tep_loglevel level, bool print_err, const char *fmt, va_list ap) { int ret = errno; - - if (errno && print_err) { - perror(name); - fprintf(stderr, " "); + FILE *fp = stdout; + + if (level <= TEP_LOG_WARNING) { + fp = stderr; + if (errno && print_err) { + perror(name); + fprintf(stderr, " "); + } } - vfprintf(stderr, fmt, ap); - fprintf(stderr, "\n"); + vfprintf(fp, fmt, ap); + fprintf(fp, "\n"); return ret; } |