1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley/*
8a99b24dbe8e0e713f226f4696bfa215b38ad3c6Tinderbox User * Copyright (C) 1999-2002, 2004-2007, 2009, 2013, 2014, 2016, 2017 Internet Systems Consortium, Inc. ("ISC")
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence *
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * file, You can obtain one at http://mozilla.org/MPL/2.0/.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley */
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
609f86163a9e80aa5ce0db79b67ee0b6e2a34b34Tatuya JINMEI 神明達哉/* $Id: log.c,v 1.49 2009/01/07 01:46:40 jinmei Exp $ */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*! \file */
9c3531d72aeaad6c5f01efe6a1c82023e1379e4dDavid Lawrence
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#include <config.h>
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
8f7cae3d7b0c122c3b17e8409bbb80005433acd2Brian Wellington#include <isc/result.h>
8f7cae3d7b0c122c3b17e8409bbb80005433acd2Brian Wellington
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington#include <isccfg/log.h>
90c099e88e9f16bfee9edee3ac1a51fc98843772Brian Wellington
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley#include <named/log.h>
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews#ifndef ISC_FACILITY
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews#define ISC_FACILITY LOG_DAEMON
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews#endif
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * When adding a new category, be sure to add the appropriate
29747dfe5e073a299b3681e01f5c55540f8bfed7Mark Andrews * \#define to <named/log.h> and to update the list in
84a5b69f0029952e33c96695f0a7d26c2bb8f7ccMark Andrews * bin/check/check-tool.c.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley */
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halleystatic isc_logcategory_t categories[] = {
5fe5a0c02634eaadfcbc3528bf2c184557110a3bAndreas Gustafsson { "", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "client", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "network", 0 },
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson { "update", 0 },
86a4d80e0624a10b1824d25018246e1ea63f55d2Andreas Gustafsson { "queries", 0 },
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews { "unmatched", 0 },
cc4928ec7116a064223f60639ca1a80f25ba350fMark Andrews { "update-security", 0 },
609f86163a9e80aa5ce0db79b67ee0b6e2a34b34Tatuya JINMEI 神明達哉 { "query-errors", 0 },
1c8aa38b53a0494fc7d4c3439594d1913987f264Mark Andrews { "trust-anchor-telementry", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { NULL, 0 }
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley};
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein/*%
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley * When adding a new module, be sure to add the appropriate
29747dfe5e073a299b3681e01f5c55540f8bfed7Mark Andrews * \#define to <dns/log.h>.
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley */
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halleystatic isc_logmodule_t modules[] = {
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "main", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "client", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "server", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "query", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { "interfacemgr", 0 },
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson { "update", 0 },
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson { "xfer-in", 0 },
8327c62a49a2487d29a37acbed6b602e629fc0eeAndreas Gustafsson { "xfer-out", 0 },
608f870f4821972313eadc5388a42fa55b6279d1Mark Andrews { "notify", 0 },
1d92d8a2456b23842a649b6104c60a9d6ea25333Brian Wellington { "control", 0 },
878d3073b13833ee1a50dfeabf8e400b6fdfc754Brian Wellington { "lwresd", 0 },
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley { NULL, 0 }
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley};
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halleyisc_result_t
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafssonns_log_init(isc_boolean_t safe) {
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley isc_result_t result;
3b1a5821011c91c3d30dc08b9dc2a4148ba77bb0Mark Andrews isc_logconfig_t *lcfg = NULL;
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley ns_g_categories = categories;
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley ns_g_modules = modules;
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley /*
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley * Setup a logging context.
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley */
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence result = isc_log_create(ns_g_mctx, &ns_g_lctx, &lcfg);
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley if (result != ISC_R_SUCCESS)
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley return (result);
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence
c55dd77de4ce71b858afb291e44577b51be8b780Mark Andrews /*
c55dd77de4ce71b858afb291e44577b51be8b780Mark Andrews * named-checktool.c:setup_logging() needs to be kept in sync.
c55dd77de4ce71b858afb291e44577b51be8b780Mark Andrews */
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence isc_log_registercategories(ns_g_lctx, ns_g_categories);
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley isc_log_registermodules(ns_g_lctx, ns_g_modules);
c90f5e8d1edbd5c277f2ee320167a12a30ba7c7bMichael Graff isc_log_setcontext(ns_g_lctx);
edcd1247ad7e81bb8b430e610d9718f64c70f05dDavid Lawrence dns_log_init(ns_g_lctx);
c90f5e8d1edbd5c277f2ee320167a12a30ba7c7bMichael Graff dns_log_setcontext(ns_g_lctx);
b31c8af1d9778ce006c7375394b5f4e5e00405bfAndreas Gustafsson cfg_log_init(ns_g_lctx);
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson if (safe)
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson result = ns_log_setsafechannels(lcfg);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson else
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson result = ns_log_setdefaultchannels(lcfg);
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson if (result != ISC_R_SUCCESS)
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson goto cleanup;
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson result = ns_log_setdefaultcategory(lcfg);
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson if (result != ISC_R_SUCCESS)
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson goto cleanup;
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson return (ISC_R_SUCCESS);
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson cleanup:
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson isc_log_destroy(&ns_g_lctx);
8bc1e5bb4ad549ef0b0a57691e4e53dc50786e3dBrian Wellington isc_log_setcontext(NULL);
8bc1e5bb4ad549ef0b0a57691e4e53dc50786e3dBrian Wellington dns_log_setcontext(NULL);
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson return (result);
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson}
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafssonisc_result_t
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafssonns_log_setdefaultchannels(isc_logconfig_t *lcfg) {
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson isc_result_t result;
e02c696ea586f8dcc7c6145cc0f143f887960cd4Andreas Gustafsson isc_logdestination_t destination;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley /*
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson * By default, the logging library makes "default_debug" log to
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson * stderr. In BIND, we want to override this and log to named.run
3fb1637c9265cc593973326ae193783413f68699Tatuya JINMEI 神明達哉 * instead, unless the -g option was given.
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley */
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson if (! ns_g_logstderr) {
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson destination.file.stream = NULL;
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson destination.file.name = "named.run";
44fee668021c7ceef4ee1c848031d883a508b359James Brister destination.file.versions = ISC_LOG_ROLLNEVER;
44fee668021c7ceef4ee1c848031d883a508b359James Brister destination.file.maximum_size = 0;
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson result = isc_log_createchannel(lcfg, "default_debug",
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington ISC_LOG_TOFILE,
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington ISC_LOG_DYNAMIC,
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington &destination,
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington ISC_LOG_PRINTTIME|
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson ISC_LOG_DEBUGONLY);
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson if (result != ISC_R_SUCCESS)
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson goto cleanup;
44fee668021c7ceef4ee1c848031d883a508b359James Brister }
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt if (ns_g_logfile != NULL) {
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.stream = NULL;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.name = ns_g_logfile;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.versions = ISC_LOG_ROLLNEVER;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.maximum_size = 0;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt result = isc_log_createchannel(lcfg, "default_logfile",
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_TOFILE,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_DYNAMIC,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt &destination,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_PRINTTIME|
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_PRINTCATEGORY|
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_PRINTLEVEL);
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt if (result != ISC_R_SUCCESS)
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt goto cleanup;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt }
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews#if ISC_FACILITY != LOG_DAEMON
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews destination.facility = ISC_FACILITY;
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews result = isc_log_createchannel(lcfg, "default_syslog",
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews ISC_LOG_TOSYSLOG, ISC_LOG_INFO,
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews &destination, 0);
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews if (result != ISC_R_SUCCESS)
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews goto cleanup;
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews#endif
ee80f4506479e189ca1320eb87ac89188c5a7848Mark Andrews
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson /*
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson * Set the initial debug level.
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson */
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel);
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson result = ISC_R_SUCCESS;
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson cleanup:
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson return (result);
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson}
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafsson
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafssonisc_result_t
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafssonns_log_setsafechannels(isc_logconfig_t *lcfg) {
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson isc_result_t result;
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews isc_logdestination_t destination;
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson if (! ns_g_logstderr) {
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson result = isc_log_createchannel(lcfg, "default_debug",
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington ISC_LOG_TONULL,
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington ISC_LOG_DYNAMIC,
78838d3e0cd62423c23de5503910e01884d2104bBrian Wellington NULL, 0);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson if (result != ISC_R_SUCCESS)
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson goto cleanup;
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson /*
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson * Setting the debug level to zero should get the output
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson * discarded a bit faster.
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson */
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson isc_log_setdebuglevel(ns_g_lctx, 0);
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson } else {
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson isc_log_setdebuglevel(ns_g_lctx, ns_g_debuglevel);
1d9ab721315555ac75e7d4f57585323909283688Andreas Gustafsson }
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt if (ns_g_logfile != NULL) {
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.stream = NULL;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.name = ns_g_logfile;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.versions = ISC_LOG_ROLLNEVER;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt destination.file.maximum_size = 0;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt result = isc_log_createchannel(lcfg, "default_logfile",
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_TOFILE,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_DYNAMIC,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt &destination,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_PRINTTIME|
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_PRINTCATEGORY|
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOG_PRINTLEVEL);
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt if (result != ISC_R_SUCCESS)
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt goto cleanup;
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt }
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews#if ISC_FACILITY != LOG_DAEMON
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews destination.facility = ISC_FACILITY;
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews result = isc_log_createchannel(lcfg, "default_syslog",
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews ISC_LOG_TOSYSLOG, ISC_LOG_INFO,
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews &destination, 0);
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews if (result != ISC_R_SUCCESS)
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews goto cleanup;
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews#endif
3b4405aba93729eead9f8f006d426f24fc4c3d78Mark Andrews
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson result = ISC_R_SUCCESS;
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson cleanup:
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson return (result);
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson}
7193a1762e428cfba06907e51fa9e4bce3b5569aAndreas Gustafsson
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafssonisc_result_t
a0f6cda5fd9f2fcc4154bb63628f849b639a40caAndreas Gustafssonns_log_setdefaultcategory(isc_logconfig_t *lcfg) {
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt isc_result_t result = ISC_R_SUCCESS;
11d435aa4cf77e035445978f7e3776a3589715fdAndreas Gustafsson
5542df09597c479be604da0ece8271cbc6fd9c4aDavid Lawrence result = isc_log_usechannel(lcfg, "default_debug",
5542df09597c479be604da0ece8271cbc6fd9c4aDavid Lawrence ISC_LOGCATEGORY_DEFAULT, NULL);
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley if (result != ISC_R_SUCCESS)
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley goto cleanup;
8582a1e113c13886ccbd1b534d6c240315767be6Bob Halley
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt if (! ns_g_logstderr) {
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt if (ns_g_logfile != NULL)
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt result = isc_log_usechannel(lcfg, "default_logfile",
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOGCATEGORY_DEFAULT,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt NULL);
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt else if (! ns_g_nosyslog)
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt result = isc_log_usechannel(lcfg, "default_syslog",
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt ISC_LOGCATEGORY_DEFAULT,
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt NULL);
44613d4d868ed5e73a1132280880f0699af56733Evan Hunt }
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley cleanup:
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley return (result);
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley}
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrewsisc_result_t
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrewsns_log_setunmatchedcategory(isc_logconfig_t *lcfg) {
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews isc_result_t result;
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews result = isc_log_usechannel(lcfg, "null",
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews NS_LOGCATEGORY_UNMATCHED, NULL);
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews return (result);
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews}
89d03d4715120fd0c968775bf0724b5a2a647539Mark Andrews
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halleyvoid
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halleyns_log_shutdown(void) {
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley isc_log_destroy(&ns_g_lctx);
8bc1e5bb4ad549ef0b0a57691e4e53dc50786e3dBrian Wellington isc_log_setcontext(NULL);
8bc1e5bb4ad549ef0b0a57691e4e53dc50786e3dBrian Wellington dns_log_setcontext(NULL);
1687985cdfc3a4c330c5bdb02c131835f8756e3cBob Halley}