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