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:
@@ -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);
|
||||
|
||||
|
@@ -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'.
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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:
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user