]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3991. [func] Add the ability to buffer logging output by specifying
authorMark Andrews <marka@isc.org>
Thu, 30 Oct 2014 00:37:05 +0000 (11:37 +1100)
committerMark Andrews <marka@isc.org>
Thu, 30 Oct 2014 00:37:05 +0000 (11:37 +1100)
                        "buffered yes;" when defining a channel. [RT #26561]

CHANGES
bin/named/logconf.c
bin/tests/system/logfileconfig/ns1/named.plain
doc/arm/Bv9ARM-book.xml
doc/arm/notes.xml
lib/isc/include/isc/log.h
lib/isc/log.c
lib/isccfg/namedconf.c

diff --git a/CHANGES b/CHANGES
index a83d0ef2a3c7a47334b579ab7ae914717124e0da..c7301607f1bba451a8162100c6689a8dc993df6c 100644 (file)
--- 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]
 
index ce804055cc39665eeae78ee94b99968b17d4365d..cc1a9229a1b37d5996b430a8dd475d0ff6672332 100644 (file)
@@ -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;
index 05caaa6715c0f78c83c208c79582346ae1a586fe..e018efba1b62fd32134d115c8c3ed8f5a683c767 100644 (file)
@@ -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 {
index 34a9f97a7a68c2741d5930cad654df221f8f9d8f..db5877c0b0f6419904b08bc2c3459444b654b147 100644 (file)
@@ -3673,6 +3673,7 @@ $ORIGIN 0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
      [ <command>print-category</command> <option>yes</option> or <option>no</option>; ]
      [ <command>print-severity</command> <option>yes</option> or <option>no</option>; ]
      [ <command>print-time</command> <option>yes</option> or <option>no</option>; ]
+     [ <command>buffered</command> <option>yes</option> or <option>no</option>; ]
    }; ]
    [ <command>category</command> <replaceable>category_name</replaceable> {
      <replaceable>channel_name</replaceable> ; [ <replaceable>channel_name</replaceable> ; ... ]
@@ -3916,6 +3917,12 @@ notrace</command>. All debugging messages in the server have a debug
            <computeroutput>28-Feb-2000 15:05:32.863 general: notice: running</computeroutput>
          </para>
 
+         <para>
+           If <command>buffered</command> has been turned on the output
+           to files will not be flushed after each log entry.  By default
+           all log messages are flushed.
+         </para>
+
          <para>
            There are four predefined channels that are used for
            <command>named</command>'s default logging as follows.
index bca0d00f048ae406e9c9b50d668d5a3cc66310f4..bf1c982b214e9c2416c270db37b56b821e6eb4ad 100644 (file)
          <filename>named.conf</filename>. [RT #35857]
        </para>
       </listitem>
+      <listitem>
+       <para>
+         Log output to files can now be buffered by specifying
+         <command>buffered yes;</command> when creating a channel.
+       </para>
+      </listitem>
     </itemizedlist>
   </sect2>
   <sect2 id="relnotes_changes">
index 0a0430f796f8266024eef873eafc332ea5b22058..72f74eaddd187294151d5607f96d676a39e400c1 100644 (file)
@@ -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
index 6bd6a2d6b57cc8aee1de442226270c30d1cacb60..be9fe12c8232df500747cf1a2536d1aa4a366b3f 100644 (file)
@@ -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
index bb3f34c10c105e9ebae0d17d7dce9118ab2cd8ce..038e84ebe883e67c96e6afb64d59c5c46a8a2470 100644 (file)
@@ -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 *