From a77e1f3abb2e8afbeb2f727f39eb784bff070b45 Mon Sep 17 00:00:00 2001 From: Martin Nagy Date: Fri, 31 Jul 2009 14:15:34 +0200 Subject: Tidy up log.c and log.h and introduce LOG_AS_ERROR The LOG_AS_ERROR conditional macro can be defined when compiling the sources to make log_debug() behave in the same way as log_error(). This is helpful for debugging, as specifying a debug level will introduce a lot of unwanted log messages. --- src/log.c | 25 +++++++------------------ src/log.h | 16 ---------------- 2 files changed, 7 insertions(+), 34 deletions(-) diff --git a/src/log.c b/src/log.c index bdf2745..636b645 100644 --- a/src/log.c +++ b/src/log.c @@ -20,36 +20,25 @@ #include #include +#include #include #include "log.h" -#define MSG_BUFFER_SIZE 2048 - -/* - * TODO: - * - Some compiler format checks would be nice. - * - Think about log_unexpected_file_line(), maybe use something else. - */ - - void log_debug(int level, const char *format, ...) { va_list args; va_start(args, format); +#ifndef LOG_AS_ERROR + UNUSED(level); isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB, - ISC_LOG_DEBUG(level), format, args); -#if 0 - /* - * For now, behave same as log_error(), so we can see every debugging - * logs without the need to specify -d. - */ + ISC_LOG_ERROR, format, args); +#else isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB, - ISC_LOG_ERROR, format, args); - (void)level; + ISC_LOG_DEBUG(level), format, args); #endif va_end(args); @@ -62,7 +51,7 @@ log_error(const char *format, ...) va_start(args, format); isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_DYNDB, - ISC_LOG_ERROR, format, args); + ISC_LOG_ERROR, format, args); va_end(args); } diff --git a/src/log.h b/src/log.h index 5446b04..6aa9931 100644 --- a/src/log.h +++ b/src/log.h @@ -25,22 +25,6 @@ #define fatal_error(...) \ isc_error_fatal(__FILE__, __LINE__, __VA_ARGS__) -/* - * Change these to use our string library. - */ - -#define log_func(logstr) log_debug(2, "%s: %s", __func__, (logstr)) -#define log_func_va(logstr, ...) \ - log_debug(2, "%s: " logstr, __func__, __VA_ARGS__) - -#define log_func_enter() log_func("entering") -#define log_func_enter_args(logstr, ...) \ - log_func_va("entering, args: " logstr, __VA_ARGS__) - -#define log_func_exit() log_func("exiting") -#define log_func_exit_result(res) \ - log_func_va("exiting with %s", isc_result_totext(res)) - /* Basic logging functions */ void log_debug(int level, const char *format, ...) ISC_FORMAT_PRINTF(2, 3); void log_error(const char *format, ...) ISC_FORMAT_PRINTF(1, 2); -- cgit