mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +00:00
log master file loading errors through the logging subsystem
by default
This commit is contained in:
@@ -105,7 +105,7 @@ test_master(char *testfile, char *origin, char *class,
|
|||||||
return(T_UNRESOLVED);
|
return(T_UNRESOLVED);
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_rdatacallbacks_init(&callbacks);
|
dns_rdatacallbacks_init_stdio(&callbacks);
|
||||||
callbacks.add = t1_add_callback;
|
callbacks.add = t1_add_callback;
|
||||||
|
|
||||||
textregion.base = class;
|
textregion.base = class;
|
||||||
|
@@ -86,7 +86,7 @@ main(int argc, char *argv[]) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_rdatacallbacks_init(&callbacks);
|
dns_rdatacallbacks_init_stdio(&callbacks);
|
||||||
callbacks.add = print_dataset;
|
callbacks.add = print_dataset;
|
||||||
|
|
||||||
result = dns_master_loadfile(argv[1], &origin, &origin, 1,
|
result = dns_master_loadfile(argv[1], &origin, &origin, 1,
|
||||||
|
@@ -15,16 +15,74 @@
|
|||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* $Id: callbacks.c,v 1.3 1999/07/30 23:32:51 halley Exp $ */
|
/* $Id: callbacks.c,v 1.4 2000/01/22 01:38:57 gson Exp $ */
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include <isc/assertions.h>
|
#include <isc/assertions.h>
|
||||||
#include <dns/callbacks.h>
|
#include <isc/util.h>
|
||||||
|
|
||||||
static void default_error_warn_callback(dns_rdatacallbacks_t *, char *, ...);
|
#include <dns/callbacks.h>
|
||||||
|
#include <dns/log.h>
|
||||||
|
|
||||||
|
static void stdio_error_warn_callback(dns_rdatacallbacks_t *, char *, ...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
stdio_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
UNUSED(callbacks);
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
isclog_error_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
UNUSED(callbacks);
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
|
DNS_LOGMODULE_MASTER, /* XXX */
|
||||||
|
ISC_LOG_ERROR, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
isclog_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
UNUSED(callbacks);
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
isc_log_vwrite(dns_lctx, DNS_LOGCATEGORY_GENERAL,
|
||||||
|
DNS_LOGMODULE_MASTER, /* XXX */
|
||||||
|
ISC_LOG_WARNING, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dns_rdatacallbacks_initcommon(dns_rdatacallbacks_t *callbacks)
|
||||||
|
|
||||||
|
{
|
||||||
|
REQUIRE(callbacks != NULL);
|
||||||
|
|
||||||
|
callbacks->add = NULL;
|
||||||
|
callbacks->add_private = NULL;
|
||||||
|
callbacks->error_private = NULL;
|
||||||
|
callbacks->warn_private = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public.
|
* Public.
|
||||||
@@ -32,28 +90,15 @@ static void default_error_warn_callback(dns_rdatacallbacks_t *, char *, ...);
|
|||||||
|
|
||||||
void
|
void
|
||||||
dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) {
|
dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks) {
|
||||||
|
dns_rdatacallbacks_initcommon(callbacks);
|
||||||
REQUIRE(callbacks != NULL);
|
callbacks->error = isclog_error_callback;
|
||||||
|
callbacks->warn = isclog_warn_callback;
|
||||||
callbacks->add = NULL;
|
|
||||||
callbacks->error = default_error_warn_callback;
|
|
||||||
callbacks->warn = default_error_warn_callback;
|
|
||||||
callbacks->add_private = NULL;
|
|
||||||
callbacks->error_private = NULL;
|
|
||||||
callbacks->warn_private = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
void
|
||||||
* Private
|
dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks) {
|
||||||
*/
|
dns_rdatacallbacks_initcommon(callbacks);
|
||||||
|
callbacks->error = stdio_error_warn_callback;
|
||||||
static void
|
callbacks->warn = stdio_error_warn_callback;
|
||||||
default_error_warn_callback(dns_rdatacallbacks_t *callbacks, char *fmt, ...) {
|
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
callbacks = callbacks; /*unused*/
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(stderr, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,10 +35,6 @@ ISC_LANG_BEGINDECLS
|
|||||||
*** Types
|
*** Types
|
||||||
***/
|
***/
|
||||||
|
|
||||||
/*
|
|
||||||
* XXXRTH These are likely to change once we've got a logging system.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct dns_rdatacallbacks {
|
typedef struct dns_rdatacallbacks {
|
||||||
/* dns_load_master calls this when it has rdatasets to commit */
|
/* dns_load_master calls this when it has rdatasets to commit */
|
||||||
dns_addrdatasetfunc_t add;
|
dns_addrdatasetfunc_t add;
|
||||||
@@ -57,17 +53,22 @@ typedef struct dns_rdatacallbacks {
|
|||||||
***/
|
***/
|
||||||
|
|
||||||
void dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks);
|
void dns_rdatacallbacks_init(dns_rdatacallbacks_t *callbacks);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initalise 'callbacks'.
|
* Initalise 'callbacks'.
|
||||||
* 'error' and 'warn' are set to default callbacks that print the
|
* 'error' and 'warn' are set to default callbacks that print the
|
||||||
* error message to stderr.
|
* error message through the DNS library log context.
|
||||||
|
*
|
||||||
* All other elements are initalised to NULL.
|
* All other elements are initalised to NULL.
|
||||||
*
|
*
|
||||||
* Requires:
|
* Requires:
|
||||||
* 'callbacks' is a valid dns_rdatacallbacks_t,
|
* 'callbacks' is a valid dns_rdatacallbacks_t,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void dns_rdatacallbacks_init_stdio(dns_rdatacallbacks_t *callbacks);
|
||||||
|
/*
|
||||||
|
* Like dns_rdatacallbacks_init, but logs to stdio.
|
||||||
|
*/
|
||||||
|
|
||||||
ISC_LANG_ENDDECLS
|
ISC_LANG_ENDDECLS
|
||||||
|
|
||||||
#endif /* DNS_CALLBACKS_H */
|
#endif /* DNS_CALLBACKS_H */
|
||||||
|
Reference in New Issue
Block a user