diff options
author | Martin Nagy <mnagy@redhat.com> | 2009-07-31 14:15:34 +0200 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2009-08-04 16:50:53 +0200 |
commit | a77e1f3abb2e8afbeb2f727f39eb784bff070b45 (patch) | |
tree | 8e7f6b39e04b3961e3dbc225737911425d97c882 | |
parent | 1d3829f127bc36710110e4c9069ee4fd1be78060 (diff) | |
download | ldap_driver-a77e1f3abb2e8afbeb2f727f39eb784bff070b45.tar.gz ldap_driver-a77e1f3abb2e8afbeb2f727f39eb784bff070b45.tar.xz ldap_driver-a77e1f3abb2e8afbeb2f727f39eb784bff070b45.zip |
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.
-rw-r--r-- | src/log.c | 25 | ||||
-rw-r--r-- | src/log.h | 16 |
2 files changed, 7 insertions, 34 deletions
@@ -20,36 +20,25 @@ #include <stdio.h> #include <isc/formatcheck.h> +#include <isc/util.h> #include <dns/log.h> #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); } @@ -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); |