Verified Commit 093a819b authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Add LOG_DEBUG_VERBOSITY environment variable

parent 29b2ab19
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ namespace env {
static constexpr auto LOG                 = ADD_PREFIX("LOG");

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

+5 −2
Original line number Diff line number Diff line
@@ -268,9 +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
           ,
           const std::string& filter,
           int verbosity
#endif
           );

@@ -408,6 +410,7 @@ struct logger {

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

    const date::time_zone * const timezone_;
+5 −2
Original line number Diff line number Diff line
@@ -225,9 +225,11 @@ process_log_filter(const std::string& log_filter) {

logger::logger(const std::string& opts, 
               const std::string& path, 
               bool trunc,
               bool trunc
#ifdef GKFS_DEBUG_BUILD
               const std::string& filter
               ,
               const std::string& filter,
               int verbosity
#endif
               ) :
    timezone_(date::current_zone()) {
@@ -238,6 +240,7 @@ logger::logger(const std::string& opts,

#ifdef GKFS_DEBUG_BUILD
    filtered_syscalls_ = process_log_filter(filter);
    debug_verbosity_ = verbosity;
#endif

    if(!path.empty()) {
+11 −2
Original line number Diff line number Diff line
@@ -51,6 +51,12 @@ PreloadContext::init_logging() {
        gkfs::env::get_var(gkfs::env::LOG_OUTPUT, DEFAULT_CLIENT_LOG_PATH);

#ifdef GKFS_DEBUG_BUILD
    // atoi returns 0 if no int conversion can be performed, which works
    // for us since if the user provides a non-numeric value we can just treat
    // it as zero
    const int log_verbosity = std::atoi(
            gkfs::env::get_var(gkfs::env::LOG_DEBUG_VERBOSITY, "0").c_str());

    const std::string log_filter =
        gkfs::env::get_var(gkfs::env::LOG_SYSCALL_FILTER, "");
#endif
@@ -60,8 +66,11 @@ PreloadContext::init_logging() {

    const bool log_trunc = !(!trunc_val.empty() && trunc_val[0] == 0);

    gkfs::log::create_global_logger(log_opts, log_output, 
                                    log_trunc, log_filter);
    gkfs::log::create_global_logger(log_opts, log_output, log_trunc
#ifdef GKFS_DEBUG_BUILD
                                    , log_filter, log_verbosity
#endif
            );
}

void PreloadContext::mountdir(const std::string& path) {