提交 e87fd8ba 编写于 作者: A Andrii Nakryiko 提交者: Alexei Starovoitov

libbpf: return previous print callback from libbpf_set_print

By returning previously set print callback from libbpf_set_print, it's
possible to restore it, eventually. This is useful when running many
independent test with one default print function, but overriding log
verbosity for particular subset of tests.
Signed-off-by: NAndrii Nakryiko <andriin@fb.com>
Signed-off-by: NAlexei Starovoitov <ast@kernel.org>
上级 8160bae2
...@@ -74,9 +74,12 @@ static int __base_pr(enum libbpf_print_level level, const char *format, ...@@ -74,9 +74,12 @@ static int __base_pr(enum libbpf_print_level level, const char *format,
static libbpf_print_fn_t __libbpf_pr = __base_pr; static libbpf_print_fn_t __libbpf_pr = __base_pr;
void libbpf_set_print(libbpf_print_fn_t fn) libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn)
{ {
libbpf_print_fn_t old_print_fn = __libbpf_pr;
__libbpf_pr = fn; __libbpf_pr = fn;
return old_print_fn;
} }
__printf(2, 3) __printf(2, 3)
......
...@@ -57,7 +57,7 @@ enum libbpf_print_level { ...@@ -57,7 +57,7 @@ enum libbpf_print_level {
typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level, typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level,
const char *, va_list ap); const char *, va_list ap);
LIBBPF_API void libbpf_set_print(libbpf_print_fn_t fn); LIBBPF_API libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn);
/* Hide internal to user */ /* Hide internal to user */
struct bpf_object; struct bpf_object;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册