mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 02:52:08 -04:00
Replace isc_log_create/destroy with isc_logconfig_get()
Add isc_logconfig_get() function to get the current logconfig and use
the getter to replace most of the little dancing around setting up
logging in the tools. Thus:
isc_log_create(mctx, &lctx, &logconfig);
isc_log_setcontext(lctx);
dns_log_setcontext(lctx);
...
...use lcfg...
...
isc_log_destroy();
is now only:
logconfig = isc_logconfig_get(lctx);
...use lcfg...
For thread-safety, isc_logconfig_get() should be surrounded by RCU read
lock, but since we never use isc_logconfig_get() in threaded context,
the only place where it is actually used (but not really needed) is
named_log_init().
This commit is contained in:
parent
a8a689531f
commit
b2dda86254
29 changed files with 60 additions and 234 deletions
|
|
@ -549,19 +549,17 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
|
|||
}
|
||||
|
||||
isc_result_t
|
||||
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
|
||||
setup_logging(isc_mem_t *mctx ISC_ATTR_UNUSED, FILE *errout, isc_log_t **logp) {
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_log_t *log = NULL;
|
||||
|
||||
isc_log_create(mctx, &log, &logconfig);
|
||||
isc_log_registercategories(log, categories);
|
||||
isc_log_setcontext(log);
|
||||
dns_log_init(log);
|
||||
dns_log_setcontext(log);
|
||||
cfg_log_init(log);
|
||||
ns_log_init(log);
|
||||
|
||||
logconfig = isc_logconfig_get(log);
|
||||
destination.file.stream = errout;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
|
|||
|
|
@ -753,10 +753,6 @@ cleanup:
|
|||
cfg_parser_destroy(&parser);
|
||||
}
|
||||
|
||||
if (logc != NULL) {
|
||||
isc_log_destroy(&logc);
|
||||
}
|
||||
|
||||
if (mctx != NULL) {
|
||||
isc_mem_destroy(&mctx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -566,9 +566,6 @@ main(int argc, char **argv) {
|
|||
fprintf(errout, "OK\n");
|
||||
}
|
||||
destroy();
|
||||
if (lctx != NULL) {
|
||||
isc_log_destroy(&lctx);
|
||||
}
|
||||
isc_mem_destroy(&mctx);
|
||||
|
||||
return ((result == ISC_R_SUCCESS) ? 0 : 1);
|
||||
|
|
|
|||
|
|
@ -322,14 +322,12 @@ setup_logging(FILE *errout) {
|
|||
isc_logconfig_t *logconfig = NULL;
|
||||
int packetlevel = 10;
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_registercategories(lctx, categories);
|
||||
isc_log_registermodules(lctx, modules);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
cfg_log_init(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
destination.file.stream = errout;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -2300,8 +2298,6 @@ cleanup:
|
|||
dns_master_styledestroy(&style, mctx);
|
||||
}
|
||||
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
|
||||
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -1361,12 +1361,11 @@ setup_libs(void) {
|
|||
|
||||
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL);
|
||||
|
||||
check_result(result, "isc_log_usechannel");
|
||||
|
||||
isc_log_setdebuglevel(lctx, 0);
|
||||
|
|
@ -4747,9 +4746,6 @@ destroy_libs(void) {
|
|||
isc_buffer_free(&namebuf);
|
||||
}
|
||||
|
||||
debug("Removing log context");
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
debug("Destroy memory");
|
||||
if (memdebugging != 0) {
|
||||
isc_mem_stats(mctx, stderr);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size) {
|
|||
}
|
||||
|
||||
void
|
||||
setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
||||
setup_logging(isc_mem_t *mctx ISC_ATTR_UNUSED, isc_log_t **logp) {
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_log_t *log = NULL;
|
||||
|
|
@ -153,10 +153,10 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
|||
break;
|
||||
}
|
||||
|
||||
isc_log_create(mctx, &log, &logconfig);
|
||||
isc_log_setcontext(log);
|
||||
dns_log_init(log);
|
||||
dns_log_setcontext(log);
|
||||
|
||||
logconfig = isc_logconfig_get(log);
|
||||
|
||||
isc_log_settag(logconfig, program);
|
||||
|
||||
/*
|
||||
|
|
@ -181,20 +181,14 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) {
|
|||
|
||||
void
|
||||
cleanup_logging(isc_log_t **logp) {
|
||||
isc_log_t *log;
|
||||
|
||||
REQUIRE(logp != NULL);
|
||||
|
||||
log = *logp;
|
||||
isc_log_t *log = *logp;
|
||||
*logp = NULL;
|
||||
|
||||
if (log == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
isc_log_destroy(&log);
|
||||
isc_log_setcontext(NULL);
|
||||
dns_log_setcontext(NULL);
|
||||
}
|
||||
|
||||
static isc_stdtime_t
|
||||
|
|
|
|||
|
|
@ -81,4 +81,4 @@ named_log_setunmatchedcategory(isc_logconfig_t *lcfg);
|
|||
*/
|
||||
|
||||
void
|
||||
named_log_shutdown(void);
|
||||
named_log_shutdown(void) __attribute__((__deprecated__));
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ isc_result_t
|
|||
named_log_init(bool safe) {
|
||||
isc_result_t result;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
isc_mem_t *log_mctx = NULL;
|
||||
|
||||
named_g_categories = categories;
|
||||
named_g_modules = modules;
|
||||
|
|
@ -59,23 +58,24 @@ named_log_init(bool safe) {
|
|||
/*
|
||||
* Setup a logging context.
|
||||
*/
|
||||
isc_mem_create(&log_mctx);
|
||||
isc_mem_setname(log_mctx, "named_log");
|
||||
isc_log_create(log_mctx, &named_g_lctx, &lcfg);
|
||||
isc_mem_detach(&log_mctx);
|
||||
|
||||
/*
|
||||
* named-checktool.c:setup_logging() needs to be kept in sync.
|
||||
*/
|
||||
isc_log_registercategories(named_g_lctx, named_g_categories);
|
||||
isc_log_registermodules(named_g_lctx, named_g_modules);
|
||||
isc_log_setcontext(named_g_lctx);
|
||||
dns_log_init(named_g_lctx);
|
||||
dns_log_setcontext(named_g_lctx);
|
||||
cfg_log_init(named_g_lctx);
|
||||
ns_log_init(named_g_lctx);
|
||||
ns_log_setcontext(named_g_lctx);
|
||||
|
||||
/*
|
||||
* This is not technically needed, as we are calling named_log_init()
|
||||
* only at the start of named process. But since the named binary is
|
||||
* the only place that also calls isc_logconfig_set(), this is a good
|
||||
* hygiene.
|
||||
*/
|
||||
rcu_read_lock();
|
||||
lcfg = isc_logconfig_get(named_g_lctx);
|
||||
if (safe) {
|
||||
named_log_setsafechannels(lcfg);
|
||||
} else {
|
||||
|
|
@ -88,13 +88,12 @@ named_log_init(bool safe) {
|
|||
}
|
||||
|
||||
named_log_setdefaultsslkeylogfile(lcfg);
|
||||
rcu_read_unlock();
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
|
||||
cleanup:
|
||||
isc_log_destroy(&named_g_lctx);
|
||||
isc_log_setcontext(NULL);
|
||||
dns_log_setcontext(NULL);
|
||||
rcu_read_unlock();
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
|
@ -251,7 +250,5 @@ named_log_setunmatchedcategory(isc_logconfig_t *lcfg) {
|
|||
|
||||
void
|
||||
named_log_shutdown(void) {
|
||||
isc_log_destroy(&named_g_lctx);
|
||||
isc_log_setcontext(NULL);
|
||||
dns_log_setcontext(NULL);
|
||||
/* no-op */
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9407,7 +9407,7 @@ load_configuration(const char *filename, named_server_t *server,
|
|||
}
|
||||
}
|
||||
|
||||
isc_logconfig_use(named_g_lctx, logc);
|
||||
isc_logconfig_set(named_g_lctx, logc);
|
||||
logc = NULL;
|
||||
|
||||
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
|
||||
|
|
|
|||
|
|
@ -812,11 +812,9 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
|
||||
ddebug("setup_system()");
|
||||
|
||||
isc_log_create(gmctx, &glctx, &logconfig);
|
||||
isc_log_setcontext(glctx);
|
||||
dns_log_init(glctx);
|
||||
dns_log_setcontext(glctx);
|
||||
|
||||
logconfig = isc_logconfig_get(glctx);
|
||||
result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL);
|
||||
check_result(result, "isc_log_usechannel");
|
||||
|
||||
|
|
@ -3488,9 +3486,6 @@ cleanup(void) {
|
|||
}
|
||||
#endif /* ifdef HAVE_GSSAPI */
|
||||
|
||||
ddebug("Removing log context");
|
||||
isc_log_destroy(&glctx);
|
||||
|
||||
ddebug("Destroying memory context");
|
||||
if (memdebugging) {
|
||||
isc_mem_stats(gmctx, stderr);
|
||||
|
|
|
|||
|
|
@ -954,8 +954,7 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_nm_settimeouts(netmgr, timeout, timeout, timeout, 0);
|
||||
|
||||
isc_log_create(rndc_mctx, &log, &logconfig);
|
||||
isc_log_setcontext(log);
|
||||
logconfig = isc_logconfig_get(log);
|
||||
isc_log_settag(logconfig, progname);
|
||||
logdest.file.stream = stderr;
|
||||
logdest.file.name = NULL;
|
||||
|
|
@ -1003,9 +1002,6 @@ main(int argc, char **argv) {
|
|||
|
||||
isccc_ccmsg_invalidate(&rndc_ccmsg);
|
||||
|
||||
isc_log_destroy(&log);
|
||||
isc_log_setcontext(NULL);
|
||||
|
||||
cfg_obj_destroy(pctx, &config);
|
||||
cfg_parser_destroy(&pctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,13 +29,6 @@
|
|||
#include <dns/name.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
#define CHECK(r) \
|
||||
do { \
|
||||
result = (r); \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
goto cleanup; \
|
||||
} while (0)
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_log_t *lctx = NULL;
|
||||
|
||||
|
|
@ -99,12 +92,10 @@ main(int argc, char **argv) {
|
|||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_registercategories(lctx, categories);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -112,7 +103,10 @@ main(int argc, char **argv) {
|
|||
isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC,
|
||||
ISC_LOG_DYNAMIC, &destination, 0);
|
||||
|
||||
CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL));
|
||||
result = isc_log_usechannel(logconfig, "stderr", NULL, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
result = loadzone(&olddb, origin, file1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -140,9 +134,6 @@ cleanup:
|
|||
dns_db_detach(&olddb);
|
||||
}
|
||||
|
||||
if (lctx != NULL) {
|
||||
isc_log_destroy(&lctx);
|
||||
}
|
||||
if (mctx != NULL) {
|
||||
isc_mem_destroy(&mctx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,8 +216,6 @@ main(int argc, char *argv[]) {
|
|||
isc_sockaddr_t bind_any;
|
||||
struct in_addr inaddr;
|
||||
isc_result_t result;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
isc_nm_t *netmgr = NULL;
|
||||
dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
dns_dispatch_t *dispatchv4 = NULL;
|
||||
|
|
@ -273,8 +271,6 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
|
||||
|
||||
isc_log_create(mctx, &lctx, &lcfg);
|
||||
|
||||
RUNCHECK(dns_dispatchmgr_create(mctx, loopmgr, netmgr, &dispatchmgr));
|
||||
|
||||
RUNCHECK(dns_dispatch_createudp(
|
||||
|
|
@ -292,8 +288,6 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_loopmgr_run(loopmgr);
|
||||
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
isc_managers_destroy(&mctx, &loopmgr, &netmgr);
|
||||
|
||||
return (0);
|
||||
|
|
|
|||
|
|
@ -105,10 +105,10 @@ main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
isc_mem_create(&mctx);
|
||||
isc_log_create(mctx, &log_, &logconfig);
|
||||
isc_log_setcontext(log_);
|
||||
|
||||
dns_log_init(log_);
|
||||
dns_log_setcontext(log_);
|
||||
|
||||
logconfig = isc_logconfig_get(log_);
|
||||
isc_log_settag(logconfig, "bigkey");
|
||||
|
||||
destination.file.stream = stderr;
|
||||
|
|
@ -144,9 +144,6 @@ main(int argc, char **argv) {
|
|||
printf("%s\n", filename);
|
||||
dst_key_free(&key);
|
||||
|
||||
isc_log_destroy(&log_);
|
||||
isc_log_setcontext(NULL);
|
||||
dns_log_setcontext(NULL);
|
||||
isc_mem_destroy(&mctx);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2111,8 +2111,6 @@ int
|
|||
main(int argc, char *argv[]) {
|
||||
struct query *query = NULL;
|
||||
isc_result_t result;
|
||||
isc_log_t *lctx = NULL;
|
||||
isc_logconfig_t *lcfg = NULL;
|
||||
unsigned int i;
|
||||
int ns;
|
||||
|
||||
|
|
@ -2129,7 +2127,6 @@ main(int argc, char *argv[]) {
|
|||
preparse_args(argc, argv);
|
||||
|
||||
isc_managers_create(&mctx, 1, &loopmgr, &netmgr);
|
||||
isc_log_create(mctx, &lctx, &lcfg);
|
||||
|
||||
isc_nonce_buf(cookie_secret, sizeof(cookie_secret));
|
||||
|
||||
|
|
@ -2190,8 +2187,6 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_loopmgr_run(loopmgr);
|
||||
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
query = ISC_LIST_HEAD(queries);
|
||||
while (query != NULL) {
|
||||
struct query *next = ISC_LIST_NEXT(query, link);
|
||||
|
|
|
|||
|
|
@ -37,16 +37,14 @@ usage(void) {
|
|||
* Setup logging to use stderr.
|
||||
*/
|
||||
static isc_result_t
|
||||
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
|
||||
setup_logging(isc_mem_t *mctx ISC_ATTR_UNUSED, FILE *errout, isc_log_t **logp) {
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_log_t *log = NULL;
|
||||
|
||||
isc_log_create(mctx, &log, &logconfig);
|
||||
isc_log_setcontext(log);
|
||||
dns_log_init(log);
|
||||
dns_log_setcontext(log);
|
||||
|
||||
logconfig = isc_logconfig_get(log);
|
||||
destination.file.stream = errout;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -127,7 +125,6 @@ main(int argc, char **argv) {
|
|||
fprintf(stderr, "%s\n", isc_result_totext(result));
|
||||
}
|
||||
}
|
||||
isc_log_destroy(&lctx);
|
||||
isc_mem_detach(&mctx);
|
||||
return (result != ISC_R_SUCCESS ? 1 : 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1060,7 +1060,7 @@ the context (`isc_log_t`) is created. The pointer to this configuration
|
|||
is returned via a parameter to `isc_log_create()` so that it can then be
|
||||
configured. A new log configuration can be established by creating
|
||||
it with `isc_logconfig_create()`, configuring it, then installing it as
|
||||
the active configuration with `isc_logconfig_use()`.
|
||||
the active configuration with `isc_logconfig_set()`.
|
||||
|
||||
##### Logging in multithreaded programs
|
||||
|
||||
|
|
|
|||
|
|
@ -73,12 +73,10 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_mem_create(&mctx);
|
||||
|
||||
isc_log_create(mctx, &lctx, &lcfg);
|
||||
isc_log_setcontext(lctx);
|
||||
|
||||
/*
|
||||
* Create and install the default channel.
|
||||
*/
|
||||
lcfg = isc_logconfig_get(lctx);
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -176,7 +174,6 @@ main(int argc, char **argv) {
|
|||
cfg_parser_destroy(&pctx);
|
||||
}
|
||||
|
||||
isc_log_destroy(&lctx);
|
||||
if (memstats) {
|
||||
isc_mem_stats(mctx, stderr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,14 +100,4 @@ dns_log_init(isc_log_t *lctx);
|
|||
* use by isc_log_usechannnel() and isc_log_write().
|
||||
*/
|
||||
|
||||
void
|
||||
dns_log_setcontext(isc_log_t *lctx);
|
||||
/*%
|
||||
* Make the libdns library use the provided context for logging internal
|
||||
* messages.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*/
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
|
|
|||
|
|
@ -57,13 +57,6 @@ isc_log_t *dns_lctx = NULL;
|
|||
|
||||
void
|
||||
dns_log_init(isc_log_t *lctx) {
|
||||
REQUIRE(lctx != NULL);
|
||||
|
||||
isc_log_registercategories(lctx, dns_categories);
|
||||
isc_log_registermodules(lctx, dns_modules);
|
||||
}
|
||||
|
||||
void
|
||||
dns_log_setcontext(isc_log_t *lctx) {
|
||||
dns_lctx = lctx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,15 +184,6 @@ extern isc_logmodule_t isc_modules[];
|
|||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp);
|
||||
/*%<
|
||||
* A dummy function that mimicks:
|
||||
*
|
||||
* isc_logconfig_create(NULL, lcfgp);
|
||||
* isc_logconfig_use(NULL, *lcfgp);
|
||||
*/
|
||||
|
||||
void
|
||||
isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp);
|
||||
/*%<
|
||||
|
|
@ -235,16 +226,16 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp);
|
|||
*\li On failure, no additional memory is allocated.
|
||||
*/
|
||||
|
||||
isc_logconfig_t *
|
||||
isc_logconfig_get(isc_log_t *lctx);
|
||||
void
|
||||
isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg);
|
||||
isc_logconfig_set(isc_log_t *lctx, isc_logconfig_t *lcfg);
|
||||
/*%<
|
||||
* Associate a new configuration with a logging context.
|
||||
* Getter/setter for a configuration with a logging context.
|
||||
*
|
||||
* Notes:
|
||||
*\li This is thread safe. The logging context will lock a mutex
|
||||
* before attempting to swap in the new configuration, and isc_log_doit
|
||||
* (the internal function used by all of isc_log_[v]write[1]) locks
|
||||
* the same lock for the duration of its use of the configuration.
|
||||
*\li The setter is thread safe. The getter is only thread-safe
|
||||
* if the isc_logconfig_get() call is protected by RCU read-lock.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
|
|
@ -254,12 +245,7 @@ isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg);
|
|||
*
|
||||
* Ensures:
|
||||
*\li Future calls to isc_log_write will use the new configuration.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_destroy(isc_log_t **lctxp);
|
||||
/*%<
|
||||
* Dummy function that does nothing.
|
||||
*\li The previous configuration object will be destroyed.
|
||||
*/
|
||||
|
||||
void
|
||||
|
|
@ -800,15 +786,6 @@ isc_log_modulebyname(isc_log_t *lctx, const char *name);
|
|||
*\li NULL if no module exists by that name.
|
||||
*/
|
||||
|
||||
void
|
||||
isc_log_setcontext(isc_log_t *lctx);
|
||||
/*%<
|
||||
* Sets the context used by the libisc for logging.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx be a valid context.
|
||||
*/
|
||||
|
||||
isc_result_t
|
||||
isc_logfile_roll(isc_logfile_t *file);
|
||||
/*%<
|
||||
|
|
|
|||
|
|
@ -288,8 +288,15 @@ isc_logconfig_create(isc_log_t *__lctx ISC_ATTR_UNUSED,
|
|||
*lcfgp = lcfg;
|
||||
}
|
||||
|
||||
isc_logconfig_t *
|
||||
isc_logconfig_get(isc_log_t *__lctx ISC_ATTR_UNUSED) {
|
||||
REQUIRE(VALID_CONTEXT(isc__lctx));
|
||||
|
||||
return (rcu_dereference(isc__lctx->logconfig));
|
||||
}
|
||||
|
||||
void
|
||||
isc_logconfig_use(isc_log_t *__lctx ISC_ATTR_UNUSED, isc_logconfig_t *lcfg) {
|
||||
isc_logconfig_set(isc_log_t *__lctx ISC_ATTR_UNUSED, isc_logconfig_t *lcfg) {
|
||||
REQUIRE(VALID_CONTEXT(isc__lctx));
|
||||
REQUIRE(VALID_CONFIG(lcfg));
|
||||
REQUIRE(lcfg->lctx == isc__lctx);
|
||||
|
|
@ -701,11 +708,6 @@ isc_log_vwrite1(isc_log_t *__lctx ISC_ATTR_UNUSED, isc_logcategory_t *category,
|
|||
isc_log_doit(NULL, category, module, level, true, format, args);
|
||||
}
|
||||
|
||||
void
|
||||
isc_log_setcontext(isc_log_t *lctx) {
|
||||
isc_lctx = lctx;
|
||||
}
|
||||
|
||||
void
|
||||
isc_log_setdebuglevel(isc_log_t *__lctx ISC_ATTR_UNUSED, unsigned int level) {
|
||||
REQUIRE(VALID_CONTEXT(isc__lctx));
|
||||
|
|
@ -1853,26 +1855,3 @@ isc__log_shutdown(void) {
|
|||
|
||||
isc_mem_putanddetach(&mctx, isc__lctx, sizeof(*isc__lctx));
|
||||
}
|
||||
|
||||
void
|
||||
isc_log_create(isc_mem_t *mctx ISC_ATTR_UNUSED, isc_log_t **lctxp,
|
||||
isc_logconfig_t **lcfgp) {
|
||||
REQUIRE(lctxp != NULL && *lctxp == NULL);
|
||||
REQUIRE(lcfgp == NULL || *lcfgp == NULL);
|
||||
REQUIRE(VALID_CONTEXT(isc__lctx));
|
||||
|
||||
isc_logconfig_create(isc__lctx, lcfgp);
|
||||
isc_logconfig_use(isc__lctx, *lcfgp);
|
||||
|
||||
*lctxp = isc__lctx;
|
||||
|
||||
rcu_read_lock();
|
||||
SET_IF_NOT_NULL(lcfgp, rcu_dereference(isc__lctx->logconfig));
|
||||
rcu_read_unlock();
|
||||
}
|
||||
|
||||
void
|
||||
isc_log_destroy(isc_log_t **lctxp ISC_ATTR_UNUSED) {
|
||||
REQUIRE(lctxp != NULL && VALID_CONTEXT(*lctxp));
|
||||
REQUIRE(*lctxp == isc__lctx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@ isc_logmodule_t cfg_modules[] = { { "isccfg/parser", 0 }, { NULL, 0 } };
|
|||
|
||||
void
|
||||
cfg_log_init(isc_log_t *lctx) {
|
||||
REQUIRE(lctx != NULL);
|
||||
|
||||
isc_log_registercategories(lctx, cfg_categories);
|
||||
isc_log_registermodules(lctx, cfg_modules);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,13 +60,3 @@ ns_log_init(isc_log_t *lctx);
|
|||
*\li The categories and modules defined above are available for
|
||||
* use by isc_log_usechannnel() and isc_log_write().
|
||||
*/
|
||||
|
||||
void
|
||||
ns_log_setcontext(isc_log_t *lctx);
|
||||
/*%<
|
||||
* Make the libns library use the provided context for logging internal
|
||||
* messages.
|
||||
*
|
||||
* Requires:
|
||||
*\li lctx is a valid logging context.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -50,13 +50,6 @@ isc_log_t *ns_lctx = NULL;
|
|||
|
||||
void
|
||||
ns_log_init(isc_log_t *lctx) {
|
||||
REQUIRE(lctx != NULL);
|
||||
|
||||
isc_log_registercategories(lctx, ns_categories);
|
||||
isc_log_registermodules(lctx, ns_modules);
|
||||
}
|
||||
|
||||
void
|
||||
ns_log_setcontext(isc_log_t *lctx) {
|
||||
ns_lctx = lctx;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -153,17 +153,15 @@ init_items(isc_mem_t *mctx) {
|
|||
}
|
||||
|
||||
static void
|
||||
init_logging(isc_mem_t *mctx) {
|
||||
init_logging(void) {
|
||||
isc_result_t result;
|
||||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
isc_log_t *lctx = NULL;
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -893,7 +891,7 @@ main(void) {
|
|||
|
||||
isc_mem_create(&mctx);
|
||||
isc_mem_setdestroycheck(mctx, true);
|
||||
init_logging(mctx);
|
||||
init_logging();
|
||||
init_items(mctx);
|
||||
|
||||
isc_loopmgr_create(mctx, nloops, &loopmgr);
|
||||
|
|
@ -902,7 +900,6 @@ main(void) {
|
|||
isc_loopmgr_run(loopmgr);
|
||||
isc_loopmgr_destroy(&loopmgr);
|
||||
|
||||
isc_log_destroy(&dns_lctx);
|
||||
isc_mem_free(mctx, item);
|
||||
isc_mem_checkdestroyed(stdout);
|
||||
isc_mem_destroy(&mctx);
|
||||
|
|
|
|||
|
|
@ -72,11 +72,9 @@ setup_logging(void) {
|
|||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_setcontext(lctx);
|
||||
dns_log_init(lctx);
|
||||
dns_log_setcontext(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -391,7 +389,6 @@ ISC_RUN_TEST_IMPL(qpmulti) {
|
|||
isc_loopmgr_run(loopmgr);
|
||||
rcu_barrier();
|
||||
isc_loopmgr_destroy(&loopmgr);
|
||||
isc_log_destroy(&dns_lctx);
|
||||
}
|
||||
|
||||
ISC_TEST_LIST_START
|
||||
|
|
|
|||
|
|
@ -52,10 +52,9 @@ ISC_SETUP_TEST_IMPL(group) {
|
|||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_registercategories(lctx, categories);
|
||||
isc_log_setcontext(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -71,17 +70,6 @@ ISC_SETUP_TEST_IMPL(group) {
|
|||
return (0);
|
||||
}
|
||||
|
||||
ISC_TEARDOWN_TEST_IMPL(group) {
|
||||
if (lctx == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
isc_log_setcontext(NULL);
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
struct duration_conf {
|
||||
const char *string;
|
||||
uint32_t time;
|
||||
|
|
@ -240,4 +228,4 @@ ISC_TEST_ENTRY(duration)
|
|||
|
||||
ISC_TEST_LIST_END
|
||||
|
||||
ISC_TEST_MAIN_CUSTOM(setup_test_group, teardown_test_group)
|
||||
ISC_TEST_MAIN_CUSTOM(setup_test_group, NULL)
|
||||
|
|
|
|||
|
|
@ -53,10 +53,9 @@ ISC_SETUP_TEST_IMPL(group) {
|
|||
isc_logdestination_t destination;
|
||||
isc_logconfig_t *logconfig = NULL;
|
||||
|
||||
isc_log_create(mctx, &lctx, &logconfig);
|
||||
isc_log_registercategories(lctx, categories);
|
||||
isc_log_setcontext(lctx);
|
||||
|
||||
logconfig = isc_logconfig_get(lctx);
|
||||
destination.file.stream = stderr;
|
||||
destination.file.name = NULL;
|
||||
destination.file.versions = ISC_LOG_ROLLNEVER;
|
||||
|
|
@ -72,17 +71,6 @@ ISC_SETUP_TEST_IMPL(group) {
|
|||
return (0);
|
||||
}
|
||||
|
||||
ISC_TEARDOWN_TEST_IMPL(group) {
|
||||
if (lctx == NULL) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
isc_log_setcontext(NULL);
|
||||
isc_log_destroy(&lctx);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* mimic calling nzf_append() */
|
||||
static void
|
||||
append(void *arg, const char *str, int len) {
|
||||
|
|
@ -225,4 +213,4 @@ ISC_TEST_ENTRY(cfg_map_nextclause)
|
|||
|
||||
ISC_TEST_LIST_END
|
||||
|
||||
ISC_TEST_MAIN_CUSTOM(setup_test_group, teardown_test_group)
|
||||
ISC_TEST_MAIN_CUSTOM(setup_test_group, NULL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue