mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Merge branch '269-refactor-zone-logging-functions' into 'master'
Refactor zone logging functions Closes #269 See merge request isc-projects/bind9!295
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -1,3 +1,5 @@
|
|||||||
|
4969. [cleanup] Refactor zone logging functions. [GL #269]
|
||||||
|
|
||||||
4968. [bug] If glue records are signed, attempt to validate them.
|
4968. [bug] If glue records are signed, attempt to validate them.
|
||||||
[GL #209]
|
[GL #209]
|
||||||
|
|
||||||
|
@@ -1968,6 +1968,15 @@ dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup);
|
|||||||
*\li 'dialup' to be a valid dialup type.
|
*\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
|
void
|
||||||
dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
|
dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...)
|
||||||
ISC_FORMAT_PRINTF(3, 4);
|
ISC_FORMAT_PRINTF(3, 4);
|
||||||
|
@@ -1209,6 +1209,7 @@ dns_zone_loadandthaw
|
|||||||
dns_zone_loadnew
|
dns_zone_loadnew
|
||||||
dns_zone_log
|
dns_zone_log
|
||||||
dns_zone_logc
|
dns_zone_logc
|
||||||
|
dns_zone_logv
|
||||||
dns_zone_maintenance
|
dns_zone_maintenance
|
||||||
dns_zone_markdirty
|
dns_zone_markdirty
|
||||||
dns_zone_name
|
dns_zone_name
|
||||||
|
113
lib/dns/zone.c
113
lib/dns/zone.c
@@ -13763,72 +13763,18 @@ dns_zone_nameonly(dns_zone_t *zone, char *buf, size_t length) {
|
|||||||
zone_name_tostr(zone, buf, length);
|
zone_name_tostr(zone, buf, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
notify_log(dns_zone_t *zone, int level, const char *fmt, ...) {
|
|
||||||
va_list ap;
|
|
||||||
char message[4096];
|
|
||||||
|
|
||||||
if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(message, sizeof(message), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_NOTIFY, DNS_LOGMODULE_ZONE,
|
|
||||||
level, "zone %s: %s", zone->strnamerd, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category,
|
dns_zone_logv(dns_zone_t *zone, isc_logcategory_t *category, int level,
|
||||||
int level, const char *fmt, ...)
|
const char *prefix, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
va_list ap;
|
|
||||||
char message[4096];
|
char message[4096];
|
||||||
|
|
||||||
if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(message, sizeof(message), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
isc_log_write(dns_lctx, category, DNS_LOGMODULE_ZONE,
|
|
||||||
level, "%s%s: %s", (zone->type == dns_zone_key) ?
|
|
||||||
"managed-keys-zone" : (zone->type == dns_zone_redirect) ?
|
|
||||||
"redirect-zone" : "zone ", zone->strnamerd, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
dns_zone_log(dns_zone_t *zone, int level, const char *fmt, ...) {
|
|
||||||
va_list ap;
|
|
||||||
char message[4096];
|
|
||||||
|
|
||||||
if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(message, sizeof(message), fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE,
|
|
||||||
level, "%s%s: %s", (zone->type == dns_zone_key) ?
|
|
||||||
"managed-keys-zone" : (zone->type == dns_zone_redirect) ?
|
|
||||||
"redirect-zone" : "zone ", zone->strnamerd, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
zone_debuglog(dns_zone_t *zone, const char *me, int debuglevel,
|
|
||||||
const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
char message[4096];
|
|
||||||
int level = ISC_LOG_DEBUG(debuglevel);
|
|
||||||
const char *zstr;
|
const char *zstr;
|
||||||
|
|
||||||
if (isc_log_wouldlog(dns_lctx, level) == ISC_FALSE)
|
if (!isc_log_wouldlog(dns_lctx, level)) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vsnprintf(message, sizeof(message), fmt, ap);
|
vsnprintf(message, sizeof(message), fmt, ap);
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
switch (zone->type) {
|
switch (zone->type) {
|
||||||
case dns_zone_key:
|
case dns_zone_key:
|
||||||
@@ -13838,12 +13784,55 @@ zone_debuglog(dns_zone_t *zone, const char *me, int debuglevel,
|
|||||||
zstr = "redirect-zone";
|
zstr = "redirect-zone";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
zstr = "zone";
|
zstr = "zone ";
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_log_write(dns_lctx, DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_ZONE,
|
isc_log_write(dns_lctx, category, DNS_LOGMODULE_ZONE, level,
|
||||||
level, "%s: %s %s: %s", me, zstr, zone->strnamerd,
|
"%s%s%s%s: %s",
|
||||||
message);
|
(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;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
dns_zone_logv(zone, DNS_LOGCATEGORY_NOTIFY, level, NULL, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category,
|
||||||
|
int level, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
dns_zone_logv(zone, category, level, NULL, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
dns_zone_log(dns_zone_t *zone, int level, const char *fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
dns_zone_logv(zone, DNS_LOGCATEGORY_GENERAL, level, NULL, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
zone_debuglog(dns_zone_t *zone, const char *me, int debuglevel,
|
||||||
|
const char *fmt, ...)
|
||||||
|
{
|
||||||
|
int level = ISC_LOG_DEBUG(debuglevel);
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
dns_zone_logv(zone, DNS_LOGCATEGORY_GENERAL, level, me, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Reference in New Issue
Block a user