From: Mark Andrews Date: Thu, 30 Oct 2014 00:37:05 +0000 (+1100) Subject: 3991. [func] Add the ability to buffer logging output by specifying X-Git-Tag: v9.11.0a1~1309 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=00fb0253c9df8a4686115745ae91d501f62c7451;p=thirdparty%2Fbind9.git 3991. [func] Add the ability to buffer logging output by specifying "buffered yes;" when defining a channel. [RT #26561] --- diff --git a/CHANGES b/CHANGES index a83d0ef2a3c..c7301607f1b 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3991. [func] Add the ability to buffer logging output by specifying + "buffered yes;" when defining a channel. [RT #26561] + 3990. [testing] Add tests for unknown DNSSEC algorithm handling. [RT #37541] diff --git a/bin/named/logconf.c b/bin/named/logconf.c index ce804055cc3..cc1a9229a1b 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -185,10 +185,12 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) const cfg_obj_t *printcat = NULL; const cfg_obj_t *printsev = NULL; const cfg_obj_t *printtime = NULL; + const cfg_obj_t *buffered = NULL; (void)cfg_map_get(channel, "print-category", &printcat); (void)cfg_map_get(channel, "print-severity", &printsev); (void)cfg_map_get(channel, "print-time", &printtime); + (void)cfg_map_get(channel, "buffered", &buffered); if (printcat != NULL && cfg_obj_asboolean(printcat)) flags |= ISC_LOG_PRINTCATEGORY; @@ -196,6 +198,8 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) flags |= ISC_LOG_PRINTTIME; if (printsev != NULL && cfg_obj_asboolean(printsev)) flags |= ISC_LOG_PRINTLEVEL; + if (buffered != NULL && cfg_obj_asboolean(buffered)) + flags |= ISC_LOG_BUFFERED; } level = ISC_LOG_INFO; diff --git a/bin/tests/system/logfileconfig/ns1/named.plain b/bin/tests/system/logfileconfig/ns1/named.plain index 05caaa6715c..e018efba1b6 100644 --- a/bin/tests/system/logfileconfig/ns1/named.plain +++ b/bin/tests/system/logfileconfig/ns1/named.plain @@ -37,6 +37,13 @@ logging { }; category default { default_log; default_debug; }; category lame-servers { null; }; + + channel query_log { + file "query_log"; + print-time yes; + buffered yes; + }; + category queries { query_log; }; }; controls { diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index 34a9f97a7a6..db5877c0b0f 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -3673,6 +3673,7 @@ $ORIGIN 0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa. [ print-category or ; ] [ print-severity or ; ] [ print-time or ; ] + [ buffered or ; ] }; ] [ category category_name { channel_name ; [ channel_name ; ... ] @@ -3916,6 +3917,12 @@ notrace. All debugging messages in the server have a debug 28-Feb-2000 15:05:32.863 general: notice: running + + If buffered has been turned on the output + to files will not be flushed after each log entry. By default + all log messages are flushed. + + There are four predefined channels that are used for named's default logging as follows. diff --git a/doc/arm/notes.xml b/doc/arm/notes.xml index bca0d00f048..bf1c982b214 100644 --- a/doc/arm/notes.xml +++ b/doc/arm/notes.xml @@ -181,6 +181,12 @@ named.conf. [RT #35857] + + + Log output to files can now be buffered by specifying + buffered yes; when creating a channel. + + diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index 0a0430f796f..72f74eaddd1 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -70,6 +70,7 @@ #define ISC_LOG_PRINTTAG 0x0010 /* tag and ":" */ #define ISC_LOG_PRINTPREFIX 0x0020 /* tag only, no colon */ #define ISC_LOG_PRINTALL 0x003F +#define ISC_LOG_BUFFERED 0x0040 #define ISC_LOG_DEBUGONLY 0x1000 #define ISC_LOG_OPENERR 0x8000 /* internal */ /*@}*/ @@ -427,8 +428,8 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, * call by defining a new channel and then calling isc_log_usechannel() * for #ISC_LOGCATEGORY_DEFAULT.) * - *\li Specifying #ISC_LOG_PRINTTIME or #ISC_LOG_PRINTTAG for syslog is allowed, - * but probably not what you wanted to do. + *\li Specifying #ISC_LOG_PRINTTIME or #ISC_LOG_PRINTTAG for syslog is + * allowed, but probably not what you wanted to do. * * #ISC_LOG_DEBUGONLY will mark the channel as usable only when the * debug level of the logging context (see isc_log_setdebuglevel) @@ -446,8 +447,8 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, * *\li level is >= #ISC_LOG_CRITICAL (the most negative logging level). * - *\li flags does not include any bits aside from the ISC_LOG_PRINT* bits - * or #ISC_LOG_DEBUGONLY. + *\li flags does not include any bits aside from the ISC_LOG_PRINT* bits, + * #ISC_LOG_DEBUGONLY or #ISC_LOG_BUFFERED. * * Ensures: *\li #ISC_R_SUCCESS diff --git a/lib/isc/log.c b/lib/isc/log.c index 6bd6a2d6b57..be9fe12c823 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -708,6 +708,8 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, { isc_logchannel_t *channel; isc_mem_t *mctx; + unsigned int permitted = ISC_LOG_PRINTALL | ISC_LOG_DEBUGONLY | + ISC_LOG_BUFFERED; REQUIRE(VALID_CONFIG(lcfg)); REQUIRE(name != NULL); @@ -715,8 +717,7 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, type == ISC_LOG_TOFILEDESC || type == ISC_LOG_TONULL); REQUIRE(destination != NULL || type == ISC_LOG_TONULL); REQUIRE(level >= ISC_LOG_CRITICAL); - REQUIRE((flags & - (unsigned int)~(ISC_LOG_PRINTALL | ISC_LOG_DEBUGONLY)) == 0); + REQUIRE((flags & ~permitted) == 0); /* XXXDCL find duplicate names? */ @@ -1415,7 +1416,7 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, struct stat statbuf; isc_boolean_t matched = ISC_FALSE; isc_boolean_t printtime, printtag, printcolon; - isc_boolean_t printcategory, printmodule, printlevel; + isc_boolean_t printcategory, printmodule, printlevel, buffered; isc_logconfig_t *lcfg; isc_logchannel_t *channel; isc_logchannellist_t *category_channels; @@ -1654,6 +1655,8 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, != 0); printlevel = ISC_TF((channel->flags & ISC_LOG_PRINTLEVEL) != 0); + buffered = ISC_TF((channel->flags & ISC_LOG_BUFFERED) + != 0); switch (channel->type) { case ISC_LOG_TOFILE: @@ -1715,7 +1718,8 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, printlevel ? level_string : "", lctx->buffer); - fflush(FILE_STREAM(channel)); + if (!buffered) + fflush(FILE_STREAM(channel)); /* * If the file now exceeds its maximum size diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index bb3f34c10c1..038e84ebe88 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -1882,6 +1882,7 @@ channel_clauses[] = { { "print-time", &cfg_type_boolean, 0 }, { "print-severity", &cfg_type_boolean, 0 }, { "print-category", &cfg_type_boolean, 0 }, + { "buffered", &cfg_type_boolean, 0 }, { NULL, NULL, 0 } }; static cfg_clausedef_t *