From 1687985cdfc3a4c330c5bdb02c131835f8756e3c Mon Sep 17 00:00:00 2001 From: Bob Halley Date: Fri, 22 Oct 1999 19:33:40 +0000 Subject: [PATCH] add log.c --- bin/named/Makefile.in | 8 ++-- bin/named/log.c | 105 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 4 deletions(-) create mode 100644 bin/named/log.c diff --git a/bin/named/Makefile.in b/bin/named/Makefile.in index 90516762f2..b8f13b4721 100644 --- a/bin/named/Makefile.in +++ b/bin/named/Makefile.in @@ -34,11 +34,11 @@ LIBS = ${DEPLIBS} \ TARGETS = named -OBJS = client.@O@ interfacemgr.@O@ main.@O@ query.@O@ rootns.@O@ \ - server.@O@ update.@O@ xfrin.@O@ xfrout.@O@ +OBJS = client.@O@ interfacemgr.@O@ log.@O@ main.@O@ query.@O@ \ + rootns.@O@ server.@O@ update.@O@ xfrin.@O@ xfrout.@O@ -SRCS = client.c interfacemgr.c main.c query.c rootns.c server.c \ - update.c xfrin.c xfrout.c +SRCS = client.c interfacemgr.c log.c main.c query.c \ + rootns.c server.c update.c xfrin.c xfrout.c @BIND9_MAKE_RULES@ diff --git a/bin/named/log.c b/bin/named/log.c new file mode 100644 index 0000000000..3902c4c10e --- /dev/null +++ b/bin/named/log.c @@ -0,0 +1,105 @@ +/* + * Copyright (C) 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#include + +#include +#include +#include + +#include + +#include +#include + +/* + * When adding a new category, be sure to add the appropriate + * #define to . + */ +static isc_logcategory_t categories[] = { + { "general", 0 }, + { "client", 0 }, + { "network", 0 }, + { NULL, 0 } +}; + +/* + * When adding a new module, be sure to add the appropriate + * #define to . + */ +static isc_logmodule_t modules[] = { + { "main", 0 }, + { "client", 0 }, + { "server", 0 }, + { "query", 0 }, + { "interfacemgr", 0 }, + { NULL, 0 } +}; + +isc_result_t +ns_log_init(void) { + isc_result_t result; + isc_logdestination_t destination; + unsigned int flags; + + ns_g_categories = categories; + ns_g_modules = modules; + + /* + * XXXRTH This is not necessarily the final default logging + * setup. + */ + + result = isc_log_create(ns_g_mctx, &ns_g_lctx); + if (result != ISC_R_SUCCESS) + return (result); + result = isc_log_registercategories(ns_g_lctx, ns_g_categories); + if (result != ISC_R_SUCCESS) + goto cleanup; + isc_log_registermodules(ns_g_lctx, ns_g_modules); + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.maximum_size = 0; + flags = ISC_LOG_PRINTTIME; + result = isc_log_createchannel(ns_g_lctx, "_default", + ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, + &destination, flags); + if (result != ISC_R_SUCCESS) + goto cleanup; + + result = isc_log_usechannel(ns_g_lctx, "_default", NULL, NULL); + if (result != ISC_R_SUCCESS) + goto cleanup; + result = dns_log_init(ns_g_lctx); + if (result != ISC_R_SUCCESS) + goto cleanup; + isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel); + + return (ISC_R_SUCCESS); + + cleanup: + isc_log_destroy(&ns_g_lctx); + + return (result); +} + +void +ns_log_shutdown(void) { + isc_log_destroy(&ns_g_lctx); +}