2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 15:05:23 +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 isc_result_t
ns_log_init(void); ns_log_init(void);
isc_result_t
ns_log_setdefaults(isc_logconfig_t *lcfg);
void void
ns_log_shutdown(void); ns_log_shutdown(void);

View File

@@ -23,7 +23,7 @@
#include <dns/conflog.h> #include <dns/conflog.h>
isc_result_t 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', * 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'. * 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 isc_result_t
ns_log_init(void) { ns_log_init(void) {
isc_result_t result; isc_result_t result;
isc_logdestination_t destination;
unsigned int flags;
isc_logconfig_t *lcfg; isc_logconfig_t *lcfg;
ns_g_categories = categories; ns_g_categories = categories;
@@ -84,6 +82,24 @@ ns_log_init(void) {
isc_log_registermodules(ns_g_lctx, ns_g_modules); isc_log_registermodules(ns_g_lctx, ns_g_modules);
dns_log_init(ns_g_lctx); 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. * Create and install the default channel.
*/ */
@@ -120,8 +136,6 @@ ns_log_init(void) {
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
cleanup: cleanup:
isc_log_destroy(&ns_g_lctx);
return (result); return (result);
} }

View File

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

View File

@@ -938,18 +938,16 @@ load_configuration(const char *filename, ns_server_t *server,
dns_c_logginglist_t *clog = NULL; dns_c_logginglist_t *clog = NULL;
isc_logconfig_t *logc = NULL; isc_logconfig_t *logc = NULL;
/* CHECKM(isc_logconfig_create(ns_g_lctx, &logc),
* dns_c_ctx_getlogging() succeeds even if there "creating new logging configuration");
* is no logging statement in named.conf; CHECKM(ns_log_setdefaults(logc),
* in that case it returns the default configuration "setting up default logging defaults");
* 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), (void) dns_c_ctx_getlogging(configctx, &clog);
"setting up logging configuration"); if (clog != NULL) {
CHECKM(ns_log_configure(logc, clog),
"configuring logging");
}
result = isc_logconfig_use(ns_g_lctx, logc); result = isc_logconfig_use(ns_g_lctx, logc);
if (result != ISC_R_SUCCESS) { if (result != ISC_R_SUCCESS) {