2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

checkpoint: restructured logging configuration code

to enable the default logging configuration to be defined
in one place
This commit is contained in:
Andreas Gustafsson
2000-03-01 00:40:54 +00:00
parent 2aee8fb2cb
commit e02c696ea5
5 changed files with 33 additions and 23 deletions

View File

@@ -47,6 +47,9 @@
isc_result_t
ns_log_init(void);
isc_result_t
ns_log_setdefaults(isc_logconfig_t *lcfg);
void
ns_log_shutdown(void);

View File

@@ -23,7 +23,7 @@
#include <dns/conflog.h>
isc_result_t
ns_logconfig_fromconf(isc_log_t *lctx, dns_c_logginglist_t *clog, isc_logconfig_t **lctxp);
ns_log_configure(isc_logconfig_t *lctx, dns_c_logginglist_t *clog);
/*
* Construct a new isc_logconfig_t object for use with the logging context 'lctx',
* configuring it according to the named.conf configuration data in 'clog'.

View File

@@ -61,8 +61,6 @@ static isc_logmodule_t modules[] = {
isc_result_t
ns_log_init(void) {
isc_result_t result;
isc_logdestination_t destination;
unsigned int flags;
isc_logconfig_t *lcfg;
ns_g_categories = categories;
@@ -84,6 +82,24 @@ ns_log_init(void) {
isc_log_registermodules(ns_g_lctx, ns_g_modules);
dns_log_init(ns_g_lctx);
result = ns_log_setdefaults(lcfg);
if (result != ISC_R_SUCCESS)
goto cleanup;
return (ISC_R_SUCCESS);
cleanup:
isc_log_destroy(&ns_g_lctx);
return (result);
}
isc_result_t
ns_log_setdefaults(isc_logconfig_t *lcfg) {
isc_result_t result;
isc_logdestination_t destination;
unsigned int flags;
/*
* Create and install the default channel.
*/
@@ -120,8 +136,6 @@ ns_log_init(void) {
return (ISC_R_SUCCESS);
cleanup:
isc_log_destroy(&ns_g_lctx);
return (result);
}

View File

@@ -163,16 +163,12 @@ channel_fromconf(dns_c_logchan_t *cchan, isc_logconfig_t *lctx)
}
isc_result_t
ns_logconfig_fromconf(isc_log_t *lctx, dns_c_logginglist_t *clog,
isc_logconfig_t **lcctxp)
ns_log_configure(isc_logconfig_t *lcctx, dns_c_logginglist_t *clog)
{
isc_result_t result;
dns_c_logchan_t *cchan;
dns_c_logcat_t *ccat;
isc_logconfig_t *lcctx = NULL;
CHECK(isc_logconfig_create(lctx, &lcctx));
for (cchan = ISC_LIST_HEAD(clog->channels);
cchan != NULL;
cchan = ISC_LIST_NEXT(cchan, next))
@@ -187,7 +183,6 @@ ns_logconfig_fromconf(isc_log_t *lctx, dns_c_logginglist_t *clog,
CHECK(category_fromconf(ccat, lcctx));
}
*lcctxp = lcctx;
return (ISC_R_SUCCESS);
cleanup:

View File

@@ -938,18 +938,16 @@ load_configuration(const char *filename, ns_server_t *server,
dns_c_logginglist_t *clog = NULL;
isc_logconfig_t *logc = NULL;
/*
* dns_c_ctx_getlogging() succeeds even if there
* is no logging statement in named.conf;
* in that case it returns the default configuration
* that was set up in logging_init(). Therefore, we
* do not need to provide any defaults of our own here.
*/
CHECKM(dns_c_ctx_getlogging(configctx, &clog),
"getting logging configuration");
CHECKM(ns_logconfig_fromconf(ns_g_lctx, clog, &logc),
"setting up logging configuration");
CHECKM(isc_logconfig_create(ns_g_lctx, &logc),
"creating new logging configuration");
CHECKM(ns_log_setdefaults(logc),
"setting up default logging defaults");
(void) dns_c_ctx_getlogging(configctx, &clog);
if (clog != NULL) {
CHECKM(ns_log_configure(logc, clog),
"configuring logging");
}
result = isc_logconfig_use(ns_g_lctx, logc);
if (result != ISC_R_SUCCESS) {