Home | History | Annotate | Line # | Download | only in ns
      1  1.1  christos /*	$NetBSD: log.c,v 1.8 2025/01/26 16:25:45 christos Exp $	*/
      2  1.1  christos 
      3  1.1  christos /*
      4  1.1  christos  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
      5  1.1  christos  *
      6  1.6  christos  * SPDX-License-Identifier: MPL-2.0
      7  1.6  christos  *
      8  1.1  christos  * This Source Code Form is subject to the terms of the Mozilla Public
      9  1.1  christos  * License, v. 2.0. If a copy of the MPL was not distributed with this
     10  1.5  christos  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
     11  1.1  christos  *
     12  1.1  christos  * See the COPYRIGHT file distributed with this work for additional
     13  1.1  christos  * information regarding copyright ownership.
     14  1.1  christos  */
     15  1.1  christos 
     16  1.1  christos /*! \file */
     17  1.1  christos 
     18  1.1  christos #include <isc/result.h>
     19  1.1  christos #include <isc/util.h>
     20  1.1  christos 
     21  1.1  christos #include <ns/log.h>
     22  1.1  christos 
     23  1.1  christos #ifndef ISC_FACILITY
     24  1.1  christos #define ISC_FACILITY LOG_DAEMON
     25  1.4  christos #endif /* ifndef ISC_FACILITY */
     26  1.1  christos 
     27  1.1  christos /*%
     28  1.1  christos  * When adding a new category, be sure to add the appropriate
     29  1.1  christos  * \#define to <ns/log.h>
     30  1.1  christos  */
     31  1.7  christos isc_logcategory_t ns_categories[] = { { "client", 0 },
     32  1.7  christos 				      { "network", 0 },
     33  1.7  christos 				      { "update", 0 },
     34  1.7  christos 				      { "queries", 0 },
     35  1.7  christos 				      { "update-security", 0 },
     36  1.7  christos 				      { "query-errors", 0 },
     37  1.7  christos 				      { "trust-anchor-telemetry", 0 },
     38  1.7  christos 				      { "serve-stale", 0 },
     39  1.8  christos 				      { "responses", 0 },
     40  1.7  christos 				      { NULL, 0 } };
     41  1.1  christos 
     42  1.1  christos /*%
     43  1.1  christos  * When adding a new module, be sure to add the appropriate
     44  1.1  christos  * \#define to <ns/log.h>.
     45  1.1  christos  */
     46  1.7  christos isc_logmodule_t ns_modules[] = {
     47  1.4  christos 	{ "ns/client", 0 }, { "ns/query", 0 },	 { "ns/interfacemgr", 0 },
     48  1.4  christos 	{ "ns/update", 0 }, { "ns/xfer-in", 0 }, { "ns/xfer-out", 0 },
     49  1.4  christos 	{ "ns/notify", 0 }, { "ns/hooks", 0 },	 { NULL, 0 }
     50  1.1  christos };
     51  1.1  christos 
     52  1.7  christos isc_log_t *ns_lctx = NULL;
     53  1.1  christos 
     54  1.1  christos void
     55  1.1  christos ns_log_init(isc_log_t *lctx) {
     56  1.1  christos 	REQUIRE(lctx != NULL);
     57  1.1  christos 
     58  1.1  christos 	isc_log_registercategories(lctx, ns_categories);
     59  1.1  christos 	isc_log_registermodules(lctx, ns_modules);
     60  1.1  christos }
     61  1.1  christos 
     62  1.1  christos void
     63  1.1  christos ns_log_setcontext(isc_log_t *lctx) {
     64  1.1  christos 	ns_lctx = lctx;
     65  1.1  christos }
     66