#include <urcu/wfcqueue.h>
+#include <isc/log.h>
#include <isc/loop.h>
#include <isc/mem.h>
#include <isc/netmgr.h>
// Memory Context
isc_mem_t* memctx;
+ // Logging
+ isc_log_t* log;
+
// Loop Manager
isc_loopmgr_t* loopmgr;
}
// Logging functions
-#define INFO(ctx, ...) logger(ctx, LOG_INFO, __VA_ARGS__)
-#define ERROR(ctx, ...) logger(ctx, LOG_ERR, __VA_ARGS__)
-#define DEBUG(ctx, ...) logger(ctx, LOG_DEBUG, __VA_ARGS__)
+#define INFO(...) logger(LOG_INFO, __VA_ARGS__)
+#define ERROR(...) logger(LOG_ERR, __VA_ARGS__)
+#define DEBUG(...) logger(LOG_DEBUG, __VA_ARGS__)
+
+static void setup_logging(void) {
+ isc_logconfig_t *logcfg = NULL;
+
+ /* Create the log context and a default config */
+ isc_log_create(ctx.memctx, &ctx.log, &logcfg);
+
+ /* Crank up debug verbosity */
+ isc_log_setdebuglevel(ctx.log, 99);
+
+ /* Define a channel that writes everything to stderr */
+ isc_logdestination_t dest = {
+ .file = {
+ .stream = stderr,
+ .name = NULL,
+ .versions = 0,
+ .maximum_size = 0,
+ },
+ };
+ isc_log_createchannel(
+ logcfg,
+ "stderr", /* channel name */
+ ISC_LOG_TOFILEDESC, /* destination type */
+ ISC_LOG_DYNAMIC, /* level — DYNAMIC follows setdebuglevel */
+ &dest,
+ ISC_LOG_PRINTTIME | ISC_LOG_PRINTLEVEL |
+ ISC_LOG_PRINTCATEGORY | ISC_LOG_PRINTMODULE);
+
+ /* Attach the channel to ALL categories/modules
+ * (NULL category = wildcard, NULL module = wildcard) */
+ isc_log_usechannel(logcfg, "stderr", NULL, NULL);
+
+ /* Tell libdns to register its categories/modules
+ * with this log context, and use it as default */
+ dns_log_init(ctx.log);
+ dns_log_setcontext(ctx.log);
+
+ /* Also make libisc itself use it */
+ isc_log_setcontext(ctx.log);
+}
static void do_zone(ctx_t* ctx, const char* name) {
DEBUG(ctx, "Processing zone %s\n", name);
// Allocate a new memory context
isc_mem_create(&ctx.memctx);
+ // Setup logging
+ setup_logging();
+
// Initialize the loop manager
isc_loopmgr_create(ctx.memctx, 1, &ctx.loopmgr);