Split dns_log_init() into dns_log_init() which sets up module and category names, and dns_log_setcontext() which sets the logging context. Call isc_log_setcontext(), dns_log_init(), and dns_log_setcontext().

This commit is contained in:
Michael Graff 2000-05-03 21:11:40 +00:00
parent 4142e747f2
commit c90f5e8d1e
24 changed files with 63 additions and 8 deletions

View file

@ -230,7 +230,9 @@ main(int argc, char *argv[]) {
if (verbose > 0) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr",
NULL, NULL) == ISC_R_SUCCESS);
}

View file

@ -209,7 +209,9 @@ main(int argc, char *argv[]) {
if (verbose > 0) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr",
NULL, NULL) == ISC_R_SUCCESS);
}

View file

@ -1374,7 +1374,9 @@ main(int argc, char *argv[]) {
if (verbose > 0) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr",
NULL, NULL) == ISC_R_SUCCESS);
}

View file

@ -237,7 +237,9 @@ main(int argc, char **argv) {
lctx = NULL;
result = isc_log_create(mem, &lctx, &lcfg);
INSIST(result == ISC_R_SUCCESS);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
destination.file.stream = stderr;
destination.file.name = NULL;

View file

@ -72,7 +72,9 @@ ns_log_init(isc_boolean_t safe) {
isc_log_registercategories(ns_g_lctx, ns_g_categories);
isc_log_registermodules(ns_g_lctx, ns_g_modules);
isc_log_setcontext(ns_g_lctx);
dns_log_init(ns_g_lctx);
dns_log_setcontext(ns_g_lctx);
if (safe)
result = ns_log_setsafechannels(lcfg);

View file

@ -79,7 +79,6 @@ XTARGETS = adb_test \
timer_test \
tkey_test \
wire_test \
zone_test \
zone2_test
# Alphabetically

View file

@ -43,6 +43,7 @@
#include <dns/log.h>
#include <dns/name.h>
#include <dns/rootns.h>
#include <dns/result.h>
typedef struct client client_t;
struct client {
@ -294,7 +295,9 @@ main(int argc, char **argv)
result = isc_log_create(mctx, &lctx, &lcfg);
check_result(result, "isc_log_create()");
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
/*
* Create and install the default channel.

View file

@ -79,7 +79,9 @@ log_init(void) {
* Setup a logging context.
*/
RUNTIME_CHECK(isc_log_create(mctx, &lctx, &lcfg) == ISC_R_SUCCESS);
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
/*
* Create and install the default channel.

View file

@ -43,6 +43,7 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/result.h>
#include "printmsg.h"

View file

@ -44,6 +44,7 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rdatatype.h>
#include <dns/result.h>
#include "printmsg.h"

View file

@ -230,7 +230,9 @@ main(int argc, char *argv[]) {
if (verbose > 0) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr",
NULL, NULL) == ISC_R_SUCCESS);
}

View file

@ -209,7 +209,9 @@ main(int argc, char *argv[]) {
if (verbose > 0) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr",
NULL, NULL) == ISC_R_SUCCESS);
}

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: log_test.c,v 1.12 2000/04/06 20:28:29 tale Exp $ */
/* $Id: log_test.c,v 1.13 2000/05/03 21:11:26 explorer Exp $ */
/* Principal Authors: DCL */
@ -118,7 +118,9 @@ main (int argc, char **argv) {
CHECK_ISC(isc_mem_create(0, 0, &mctx));
CHECK_ISC(isc_log_create(mctx, &lctx, &lcfg));
isc_log_setcontext(lctx);
dns_log_init(lctx);
dns_log_setcontext(lctx);
/*
* Test isc_log_categorybyname and isc_log_modulebyname.

View file

@ -113,7 +113,9 @@ int main (int argc, char **argv) {
RUNTIME_CHECK(isc_mem_create(0, 0, &mem) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_log_create(mem, &log, &logcfg) == ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logcfg, "default_stderr", NULL, NULL)
== ISC_R_SUCCESS);

View file

@ -58,7 +58,9 @@ int main (int argc, char **argv) {
RUNTIME_CHECK(isc_mem_create(0, 0, &mem) == ISC_R_SUCCESS);
RUNTIME_CHECK(isc_log_create(mem, &log, &logcfg) == ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logcfg, "default_stderr", NULL, NULL)
== ISC_R_SUCCESS);

View file

@ -25,6 +25,7 @@
#include <dns/rbt.h>
#include <dns/fixedname.h>
#include <dns/result.h>
char *progname;
isc_mem_t *mctx;

View file

@ -29,6 +29,7 @@
#include <isc/thread.h>
#include <isc/result.h>
#include <isc/timer.h>
#include <isc/time.h>
#include <isc/mutex.h>
#include <isc/condition.h>
#include <isc/event.h>

View file

@ -1374,7 +1374,9 @@ main(int argc, char *argv[]) {
if (verbose > 0) {
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig)
== ISC_R_SUCCESS);
isc_log_setcontext(log);
dns_log_init(log);
dns_log_setcontext(log);
RUNTIME_CHECK(isc_log_usechannel(logconfig, "default_stderr",
NULL, NULL) == ISC_R_SUCCESS);
}

View file

@ -27,6 +27,7 @@
#include <isc/result.h>
#include <isc/symtab.h>
#include <isc/util.h>
#include <isc/mem.h>
isc_mem_t *mctx;
isc_symtab_t *st;

View file

@ -52,6 +52,8 @@
#include <dns/keyvalues.h>
#include <dns/view.h>
#include <dst/result.h>
#define CHECK(str, x) { \
if ((x) != ISC_R_SUCCESS) { \
printf("%s: %s\n", (str), isc_result_totext(x)); \

View file

@ -33,6 +33,7 @@
#include <dns/zone.h>
#include <dns/zoneconf.h>
#include <dns/zt.h>
#include <dns/result.h>
#define ERRRET(result, function) \
do { \

View file

@ -31,6 +31,8 @@
#include <dns/zone.h>
#include <dns/rdataclass.h>
#include <dns/result.h>
static int debug = 0;
static int quiet = 0;
static int stats = 0;

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: log.h,v 1.17 2000/05/02 03:54:08 tale Exp $ */
/* $Id: log.h,v 1.18 2000/05/03 21:11:40 explorer Exp $ */
/* Principal Authors: DCL */
@ -66,7 +66,7 @@ ISC_LANG_BEGINDECLS
void
dns_log_init(isc_log_t *lctx);
/*
* Make the libdns.a categories and modules available for use with the
* Make the libdns categories and modules available for use with the
* ISC logging library.
*
* Requires:
@ -79,6 +79,18 @@ 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:
* lctx is a valid logging context.
*
* dns_log_setcontext() is called only once.
*/
ISC_LANG_ENDDECLS
#endif /* DNS_LOG_H */

View file

@ -15,7 +15,7 @@
* SOFTWARE.
*/
/* $Id: log.c,v 1.19 2000/04/29 00:45:24 explorer Exp $ */
/* $Id: log.c,v 1.20 2000/05/03 21:11:38 explorer Exp $ */
/* Principal Authors: DCL */
@ -72,14 +72,21 @@ isc_logmodule_t dns_modules[] = {
{ NULL, 0 }
};
isc_log_t *dns_lctx;
isc_log_t *dns_lctx = NULL;
void
dns_log_init(isc_log_t *lctx) {
REQUIRE(dns_lctx == NULL);
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)
{
REQUIRE(dns_lctx == NULL);
dns_lctx = lctx;
}