On Tue, 2024-03-05 at 11:24 -0800, Andrii Nakryiko wrote: [...] > > +char *stop_libbpf_log_capture(void) > > +{ > > + char *buf; > > + > > + if (!libbpf_capture_stream) > > + return NULL; > > + > > + fputc(0, libbpf_capture_stream); > > + fclose(libbpf_capture_stream); > > + libbpf_capture_stream = NULL; > > + /* get 'buf' after fclose(), see open_memstream() documentation */ > > + buf = libbpf_output_capture.buf; > > + bzero(&libbpf_output_capture, sizeof(libbpf_output_capture)); > > please use memset(): > > $ rg -w memset | wc -l > 355 > $ rg -w bzero | wc -l > 12 Ok, will do > > + return buf; > > +} > > + > > static int libbpf_print_fn(enum libbpf_print_level level, > > const char *format, va_list args) > > { > > + if (libbpf_capture_stream) { > > + va_list args2; > > + > > + va_copy(args2, args); > > + vfprintf(libbpf_capture_stream, format, args2); > > + } > > should we take into account verbosity settings? capturing LIBBPF_DEBUG > logs probably isn't very useful (but will make debugging harder, > probably) LIBBPF_DEBUG messages are not necessary for my tests, so I'll move this down after verbosity check, could be changed later if need be.