1999-10-22 19:33:40 +00:00
|
|
|
/*
|
2000-02-03 22:29:57 +00:00
|
|
|
* Copyright (C) 1999, 2000 Internet Software Consortium.
|
1999-10-22 19:33:40 +00:00
|
|
|
*
|
|
|
|
* 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 <config.h>
|
|
|
|
|
|
|
|
#include <isc/assertions.h>
|
|
|
|
#include <isc/log.h>
|
|
|
|
#include <isc/result.h>
|
|
|
|
|
|
|
|
#include <dns/log.h>
|
|
|
|
|
|
|
|
#include <named/globals.h>
|
|
|
|
#include <named/log.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When adding a new category, be sure to add the appropriate
|
|
|
|
* #define to <named/log.h>.
|
|
|
|
*/
|
|
|
|
static isc_logcategory_t categories[] = {
|
|
|
|
{ "general", 0 },
|
|
|
|
{ "client", 0 },
|
|
|
|
{ "network", 0 },
|
1999-10-23 00:44:40 +00:00
|
|
|
{ "update", 0 },
|
|
|
|
{ "xfer-in", 0 },
|
|
|
|
{ "xfer-out", 0 },
|
1999-12-14 07:47:35 +00:00
|
|
|
{ "notify", 0 },
|
1999-10-22 19:33:40 +00:00
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When adding a new module, be sure to add the appropriate
|
|
|
|
* #define to <dns/log.h>.
|
|
|
|
*/
|
|
|
|
static isc_logmodule_t modules[] = {
|
|
|
|
{ "main", 0 },
|
|
|
|
{ "client", 0 },
|
|
|
|
{ "server", 0 },
|
|
|
|
{ "query", 0 },
|
|
|
|
{ "interfacemgr", 0 },
|
1999-10-23 00:44:40 +00:00
|
|
|
{ "update", 0 },
|
|
|
|
{ "xfer-in", 0 },
|
|
|
|
{ "xfer-out", 0 },
|
1999-12-14 07:47:35 +00:00
|
|
|
{ "notify", 0 },
|
1999-10-22 19:33:40 +00:00
|
|
|
{ NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
ns_log_init(void) {
|
|
|
|
isc_result_t result;
|
2000-02-26 19:57:02 +00:00
|
|
|
isc_logconfig_t *lcfg;
|
1999-10-22 19:33:40 +00:00
|
|
|
|
|
|
|
ns_g_categories = categories;
|
|
|
|
ns_g_modules = modules;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXXRTH This is not necessarily the final default logging
|
|
|
|
* setup.
|
|
|
|
*/
|
|
|
|
|
1999-10-23 00:32:48 +00:00
|
|
|
/*
|
|
|
|
* Setup a logging context.
|
|
|
|
*/
|
2000-02-26 19:57:02 +00:00
|
|
|
result = isc_log_create(ns_g_mctx, &ns_g_lctx, &lcfg);
|
1999-10-22 19:33:40 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
return (result);
|
2000-02-26 19:57:02 +00:00
|
|
|
|
|
|
|
isc_log_registercategories(ns_g_lctx, ns_g_categories);
|
1999-10-22 19:33:40 +00:00
|
|
|
isc_log_registermodules(ns_g_lctx, ns_g_modules);
|
2000-02-26 19:57:02 +00:00
|
|
|
dns_log_init(ns_g_lctx);
|
1999-10-23 00:32:48 +00:00
|
|
|
|
2000-03-01 00:40:54 +00:00
|
|
|
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;
|
|
|
|
|
1999-10-23 00:32:48 +00:00
|
|
|
/*
|
2000-03-01 20:40:14 +00:00
|
|
|
* By default, the logging library makes "default_debug" log to
|
|
|
|
* stderr. In BIND, we want to override this and log to named.run
|
|
|
|
* instead, unless the the -g option was given.
|
1999-10-23 00:32:48 +00:00
|
|
|
*/
|
2000-03-01 20:40:14 +00:00
|
|
|
if (! ns_g_logstderr) {
|
|
|
|
destination.file.stream = NULL;
|
|
|
|
destination.file.name = "named.run";
|
2000-01-26 17:35:16 +00:00
|
|
|
destination.file.versions = ISC_LOG_ROLLNEVER;
|
|
|
|
destination.file.maximum_size = 0;
|
2000-03-01 20:40:14 +00:00
|
|
|
result = isc_log_createchannel(lcfg, "default_debug",
|
|
|
|
ISC_LOG_TOFILE,
|
|
|
|
ISC_LOG_DYNAMIC,
|
|
|
|
&destination,
|
|
|
|
ISC_LOG_PRINTTIME|
|
|
|
|
ISC_LOG_DEBUGONLY);
|
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2000-01-26 17:35:16 +00:00
|
|
|
}
|
2000-03-01 20:40:14 +00:00
|
|
|
|
2000-03-04 16:41:48 +00:00
|
|
|
result = isc_log_usechannel(lcfg, "default_syslog",
|
|
|
|
ISC_LOGCATEGORY_DEFAULT, NULL);
|
1999-10-22 19:33:40 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
2000-03-01 20:40:14 +00:00
|
|
|
|
2000-03-04 16:41:48 +00:00
|
|
|
result = isc_log_usechannel(lcfg, "default_debug",
|
|
|
|
ISC_LOGCATEGORY_DEFAULT, NULL);
|
1999-10-22 19:33:40 +00:00
|
|
|
if (result != ISC_R_SUCCESS)
|
|
|
|
goto cleanup;
|
1999-10-23 00:32:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the initial debug level.
|
|
|
|
*/
|
1999-10-22 19:33:40 +00:00
|
|
|
isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel);
|
|
|
|
|
|
|
|
return (ISC_R_SUCCESS);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
return (result);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ns_log_shutdown(void) {
|
|
|
|
isc_log_destroy(&ns_g_lctx);
|
|
|
|
}
|