log.c revision 1687985cdfc3a4c330c5bdb02c131835f8756e3c
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington/*
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * Copyright (C) 1999 Internet Software Consortium.
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington *
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * Permission to use, copy, modify, and distribute this software for any
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * purpose with or without fee is hereby granted, provided that the above
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * copyright notice and this permission notice appear in all copies.
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington *
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * SOFTWARE.
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington */
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <config.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <isc/assertions.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <isc/log.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <isc/result.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <dns/log.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <named/globals.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington#include <named/log.h>
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington/*
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * When adding a new category, be sure to add the appropriate
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * #define to <named/log.h>.
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington */
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellingtonstatic isc_logcategory_t categories[] = {
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "general", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "client", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "network", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { NULL, 0 }
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington};
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington/*
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * When adding a new module, be sure to add the appropriate
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington * #define to <dns/log.h>.
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington */
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellingtonstatic isc_logmodule_t modules[] = {
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "main", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "client", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "server", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "query", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { "interfacemgr", 0 },
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington { NULL, 0 }
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington};
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellingtonisc_result_t
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellingtonns_log_init(void) {
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington isc_result_t result;
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington isc_logdestination_t destination;
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington unsigned int flags;
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington
bf49a52178db60df60f2316a3977b2249f7c0edbBrian Wellington 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);
}