]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add dns_zone_logv()
authorMichał Kępień <michal@isc.org>
Mon, 11 Jun 2018 10:49:06 +0000 (12:49 +0200)
committerMichał Kępień <michal@isc.org>
Mon, 11 Jun 2018 10:50:25 +0000 (12:50 +0200)
Add a new libdns function, dns_zone_logv(), which takes a single va_list
argument rather than a variable number of arguments and can be used as a
base for implementing more specific zone logging functions.

(cherry picked from commit bb2dfb3f49ab707d751c0d83eb26938ed29a1b70)

lib/dns/include/dns/zone.h
lib/dns/win32/libdns.def.in
lib/dns/zone.c

index fb3cfe54100102124a324a542edbf945acaf13fb..4808aa555afa83bf7728a1b5041d439f8985fa5f 100644 (file)
@@ -1998,6 +1998,15 @@ dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup);
  *\li  'dialup' to be a valid dialup type.
  */
 
+void
+dns_zone_logv(dns_zone_t *zone, isc_logcategory_t *category, int level,
+             const char *prefix, const char *msg, va_list ap);
+/*%<
+ * Log the message 'msg...' at 'level' using log category 'category', including
+ * text that identifies the message as applying to 'zone'.  If the (optional)
+ * 'prefix' is not NULL, it will be placed at the start of the entire log line.
+ */
+
 void
 dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
        ISC_FORMAT_PRINTF(3, 4);
index dc16e9b29c5e291bc73c32ed75db93b72e96924c..d48eeb282297ed70653d246ca18db1e43e511e38 100644 (file)
@@ -1257,6 +1257,7 @@ dns_zone_loadandthaw
 dns_zone_loadnew
 dns_zone_log
 dns_zone_logc
+dns_zone_logv
 dns_zone_maintenance
 dns_zone_markdirty
 dns_zone_name
index 6a24305ed2f87530e1eded7e1799bf46703cfd39..dc41a7b1b043b7784dcf9517112194895a3f0fcd 100644 (file)
@@ -13727,6 +13727,37 @@ dns_zone_nameonly(dns_zone_t *zone, char *buf, size_t length) {
        zone_name_tostr(zone, buf, length);
 }
 
+void
+dns_zone_logv(dns_zone_t *zone, isc_logcategory_t *category, int level,
+             const char *prefix, const char *fmt, va_list ap)
+{
+       char message[4096];
+       const char *zstr;
+
+       if (!isc_log_wouldlog(dns_lctx, level)) {
+               return;
+       }
+
+       vsnprintf(message, sizeof(message), fmt, ap);
+
+       switch (zone->type) {
+       case dns_zone_key:
+               zstr = "managed-keys-zone";
+               break;
+       case dns_zone_redirect:
+               zstr = "redirect-zone";
+               break;
+       default:
+               zstr = "zone ";
+       }
+
+       isc_log_write(dns_lctx, category, DNS_LOGMODULE_ZONE, level,
+                     "%s%s%s%s: %s",
+                     (prefix != NULL ? prefix : ""),
+                     (prefix != NULL ? ": " : ""),
+                     zstr, zone->strnamerd, message);
+}
+
 static void
 notify_log(dns_zone_t *zone, int level, const char *fmt, ...) {
        va_list ap;