Unverified Commit 473ef38e authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Specific syscalls can now be removed from log output

parent 9464ffd3
Loading
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -169,6 +169,11 @@ The following modules are available:
 - `all`: All previous options combined.
 - `help`: Print a help message and exit.

When tracing sytem calls, specific syscalls can be removed from log messages by
setting the `LIBGKFS_LOG_SYSCALL_FILTER` environment variable. For instance,
setting it to `LIBGKFS_LOG_SYSCALL_FILTER=epoll_wait,epoll_create` will filter
out any log entries from the `epoll_wait()` and `epoll_create()` system calls.

Additionally, setting the `LIBGKFS_LOG_OUTPUT_TRUNC` environment variable with
a value different from `0` will instruct the logging subsystem to truncate 
the file used for logging, rather than append to it.
+10 −5
Original line number Diff line number Diff line
@@ -23,6 +23,11 @@ namespace gkfs {
namespace env {

static constexpr auto LOG                = ADD_PREFIX("LOG");

#ifdef GKFS_DEBUG_BUILD
static constexpr auto LOG_SYSCALL_FILTER = ADD_PREFIX("LOG_SYSCALL_FILTER");
#endif

static constexpr auto LOG_OUTPUT         = ADD_PREFIX("LOG_OUTPUT");
static constexpr auto LOG_OUTPUT_TRUNC   = ADD_PREFIX("LOG_OUTPUT_TRUNC");
static constexpr auto CWD                = ADD_PREFIX("CWD");
+14 −1
Original line number Diff line number Diff line
@@ -24,6 +24,10 @@
#include <fmt/ostr.h>
#include <date/tz.h>

#ifdef GKFS_DEBUG_BUILD
#include <bitset>
#endif

namespace gkfs {
namespace log {

@@ -264,7 +268,11 @@ struct logger {

    logger(const std::string& opts, 
           const std::string& path, 
           bool trunc);
           bool trunc,
#ifdef GKFS_DEBUG_BUILD
           const std::string& filter
#endif
           );

    ~logger();

@@ -397,6 +405,11 @@ struct logger {

    int log_fd_;
    log_level log_mask_;

#ifdef GKFS_DEBUG_BUILD
    std::bitset<512> filtered_syscalls_;
#endif

    const date::time_zone * const timezone_;
};

+2 −2
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ decode(FmtBuffer& buffer,

    detail::errno_saver _(errno);

    const auto sc = lookup_syscall(syscall_number, argv);
    const auto sc = lookup_by_number(syscall_number, argv);

    fmt::format_to(buffer, "{}(", sc.name());

@@ -71,7 +71,7 @@ decode(FmtBuffer& buffer,

    detail::errno_saver _(errno);

    const auto sc = lookup_syscall(syscall_number, argv);
    const auto sc = lookup_by_number(syscall_number, argv);

    fmt::format_to(buffer, "{}(", sc.name());

+5 −0
Original line number Diff line number Diff line
@@ -66,9 +66,14 @@ struct syscall_info {
};

extern const struct syscall_info syscall_table[];

extern const struct syscall_info* 
get_syscall_info(const long syscall_number, 
                 const long* argv);

extern const struct syscall_info* 
get_syscall_info_by_name(const char* syscall_name);

extern bool 
syscall_never_returns(long);

Loading