From 801b219e3fb01eeeee45ce7b28f6d3a43c7559f1 Mon Sep 17 00:00:00 2001 From: li-long315 Date: Sun, 25 Jun 2023 14:38:43 +0800 Subject: [PATCH] Add print function for libbpf --- observation/src/ttysnoop/ttysnoop.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/observation/src/ttysnoop/ttysnoop.c b/observation/src/ttysnoop/ttysnoop.c index 2945e9f7..466ff738 100644 --- a/observation/src/ttysnoop/ttysnoop.c +++ b/observation/src/ttysnoop/ttysnoop.c @@ -99,6 +99,14 @@ static error_t parse_arg(int key, char *arg, struct argp_state *state) return 0; } +static int libbpf_print_fn(enum libbpf_print_level level, const char *format, + va_list args) +{ + if (level == LIBBPF_DEBUG && !env.verbose) + return 0; + return vfprintf(stderr, format, args); +} + static bool tty_write_is_newly(void) { const struct btf_type *type; @@ -160,6 +168,7 @@ int main(int argc, char *argv[]) } new_tty_write = tty_write_is_newly(); + libbpf_set_print(libbpf_print_fn); return err != 0; } -- Gitee