[BUG] SPDLOG won't output anything in the agent code
I've noted that I cannot see any log messages from SPDLOG in the target process's agent code. For example, I have to patch the ringbuf::reserve function like below actually to see the log messages and error messages:
diff --git a/runtime/src/bpf_map/userspace/ringbuf_map.cpp b/runtime/src/bpf_map/userspace/ringbuf_map.cpp
index fcfb169..66e9ca8 100644
--- a/runtime/src/bpf_map/userspace/ringbuf_map.cpp
+++ b/runtime/src/bpf_map/userspace/ringbuf_map.cpp
@@ -182,8 +182,8 @@ void *ringbuf::reserve(size_t size, int self_fd)
{
if (size & (BPF_RINGBUF_BUSY_BIT | BPF_RINGBUF_DISCARD_BIT)) {
errno = E2BIG;
- SPDLOG_ERROR(
- "Try to reserve an area of {} bytes, which is too big for ringbuf map {}",
+ fprintf(stderr,
+ "Try to reserve an area of %zu bytes, which is too big for ringbuf map %d\n",
size, self_fd);
return nullptr;
}
@@ -206,7 +206,7 @@ void *ringbuf::reserve(size_t size, int self_fd)
header->fd = self_fd;
smp_store_release_ul(producer_pos.get(), prod_pos + total_size);
auto ptr = data.get() + ((prod_pos + BPF_RINGBUF_HDR_SZ) & mask());
- SPDLOG_TRACE("ringbuf: reserved {} bytes at {}, fd {}", size,
+ fprintf(stderr, "ringbuf: reserved %zu bytes at %p, fd %d\n", size,
(void *)ptr, self_fd);
return ptr;
}
Can we have a better solution here? BTW, I already set the SPDLOG_LEVEL=Debug system environment.
Are you using the release build of bpftime?
The release build of runtime may not emit drbug info, since it's configed with -DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO.
I was thinking that disabling debug and trace log may reduce the unnecessary log overhead and improve the performance. Shall we remve this config from the release build?
reference: https://eunomia.dev/bpftime/documents/usage/#control-log-level
Solved.