From: Lukáš Ježek Date: Tue, 4 May 2021 10:03:26 +0000 (+0200) Subject: log: remove kr_verbose_status X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1701d9ec2843669a6560b4551f2573f8e96edefc;p=thirdparty%2Fknot-resolver.git log: remove kr_verbose_status --- diff --git a/daemon/io.c b/daemon/io.c index 255f67c4a..d8aa8da65 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -280,7 +280,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) } if (nread < 0 || !buf->base) { - if (kr_verbose_status) { + if (KR_LOG_LEVEL_IS(LOG_DEBUG)) { struct sockaddr *peer = session_get_peer(s); char *peer_str = kr_straddr(peer); kr_log_verbose("[io] => connection to '%s' closed by peer (%s)\n", @@ -299,7 +299,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) Decode data free space in session wire buffer. */ consumed = tls_process_input_data(s, (const uint8_t *)buf->base, nread); if (consumed < 0) { - if (kr_verbose_status) { + if (KR_LOG_LEVEL_IS(LOG_DEBUG)) { struct sockaddr *peer = session_get_peer(s); char *peer_str = kr_straddr(peer); kr_log_verbose("[io] => connection to '%s': " @@ -318,7 +318,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) if (session_flags(s)->has_http) { consumed = http_process_input_data(s, data, data_len); if (consumed < 0) { - if (kr_verbose_status) { + if (KR_LOG_LEVEL_IS(LOG_DEBUG)) { struct sockaddr *peer = session_get_peer(s); char *peer_str = kr_straddr(peer); kr_log_verbose("[io] => connection to '%s': " diff --git a/lib/cache/nsec1.c b/lib/cache/nsec1.c index 32e969eb7..f6bf72758 100644 --- a/lib/cache/nsec1.c +++ b/lib/cache/nsec1.c @@ -424,7 +424,7 @@ int nsec1_src_synth(struct key *k, struct answer *ans, const knot_dname_t *clenc if (kr_fails_assert(nsec_rr)) return kr_error(EFAULT); const uint32_t new_ttl_log = - kr_verbose_status ? nsec_rr->ttl : -1; + KR_LOG_LEVEL_IS(LOG_DEBUG) ? nsec_rr->ttl : -1; const uint8_t *bm = knot_nsec_bitmap(nsec_rr->rrs.rdata); uint16_t bm_size = knot_nsec_bitmap_len(nsec_rr->rrs.rdata); int ret; diff --git a/lib/log.c b/lib/log.c index b5bb4da24..ec2ca9c6d 100644 --- a/lib/log.c +++ b/lib/log.c @@ -12,7 +12,7 @@ void kr_log_fmt(log_level_t level, const char *fmt, ...) { va_list args; va_start(args, fmt); - if (level <= kr_log_level) + if (KR_LOG_LEVEL_IS(level)) vfprintf(stdout, fmt, args); va_end(args); } @@ -31,7 +31,7 @@ int kr_log_level_set(log_level_t level) /* gnutls logs messages related to our TLS and also libdnssec, * and the logging is set up in a global way only */ - if (kr_log_level >= LOG_DEBUG) { + if (KR_LOG_LEVEL_IS(LOG_DEBUG)) { gnutls_global_set_log_function(kres_gnutls_log); } gnutls_global_set_log_level(level); diff --git a/lib/log.h b/lib/log.h index a855768f8..31c51ea18 100644 --- a/lib/log.h +++ b/lib/log.h @@ -30,3 +30,5 @@ void kr_log_init(log_level_t level); #define kr_log_fatal(fmt, ...) kr_log_fmt(LOG_CRIT, fmt, ## __VA_ARGS__) #define kr_log_deprecate(fmt, ...) kr_log_fmt(LOG_WARNING, "deprecation WARNING: " fmt, ## __VA_ARGS__) + +#define KR_LOG_LEVEL_IS(exp) ((kr_log_level >= exp) ? true : false) diff --git a/lib/utils.c b/lib/utils.c index b37c13b1f..be6f21cad 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -31,11 +31,7 @@ #include #include -/* Always compile-in log symbols, even if disabled. */ -#undef kr_verbose_status - /* Logging & debugging */ -bool kr_verbose_status = false; bool kr_dbg_assertion_abort = DBG_ASSERTION_ABORT; int kr_dbg_assertion_fork = DBG_ASSERTION_FORK; @@ -69,7 +65,6 @@ recover: errno = errno_orig; } - /* * Macros. */ diff --git a/lib/utils.h b/lib/utils.h index 6fb1a76bc..f28b65e17 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -96,10 +96,6 @@ static inline bool kr_assert_func(bool result, const char *expr, const char *fun return result; } -/* Always export these, but override direct calls by macros conditionally. */ -/** Whether in --verbose mode. Only use this for reading. */ -KR_EXPORT extern bool kr_verbose_status; - /** * @brief Return true if the query has request log handler installed. */ @@ -133,15 +129,9 @@ void kr_log_req(const struct kr_request * const req, uint32_t qry_uid, KR_EXPORT KR_PRINTF(3) void kr_log_q(const struct kr_query *qry, const char *source, const char *fmt, ...); -#ifdef NOVERBOSELOG -/* Efficient compile-time disabling of verbose messages. */ -#define kr_verbose_status false -#define kr_verbose_set(x) -#endif - /** Block run in --verbose mode; optimized when not run. */ -#define VERBOSE_STATUS __builtin_expect(kr_verbose_status, false) -#define WITH_VERBOSE(query) if(__builtin_expect(kr_verbose_status || kr_log_qtrace_enabled(query), false)) +#define VERBOSE_STATUS __builtin_expect(KR_LOG_LEVEL_IS(LOG_DEBUG), false) +#define WITH_VERBOSE(query) if(__builtin_expect(KR_LOG_LEVEL_IS(LOG_DEBUG) || kr_log_qtrace_enabled(query), false)) #define kr_log_verbose if(VERBOSE_STATUS) printf #define KR_DNAME_GET_STR(dname_str, dname) \