]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Author: Tim Starling <unknown>
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 31 Aug 2009 10:02:23 +0000 (22:02 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 31 Aug 2009 10:02:23 +0000 (22:02 +1200)
Port 2.7: Unique sequence number per log line

Create and enable logging of a unique sequence number per log entry.

Adjusted to 64-bit to handle long Squid up times with very large logged
line counts.

NP: not quite sure about the incrementation. Write appears to be called
once per log entry but this is not tested under enough conditions to be
certain yet. The old lineEnd call from Squid-2 is not present in Squid-3.

doc/release-notes/release-3.2.sgml
src/access_log.cc
src/cf.data.pre
src/logfile.cc
src/structs.h

index df4d4992a7c9ef7773e647d0f3ae6b63ae0285e1..cfd974717ac32fa61af8d6cd272dac65a5dff297 100644 (file)
@@ -268,6 +268,9 @@ This section gives a thorough account of those changes in three categories:
 <sect1>Changes to existing tags<label id="modifiedtags">
 <p>
 <descrip>
+       <tag>logformat</tag>
+       <p><em>%sn</em> Unique sequence number per log line. Ported from 2.7
+
        <tag>windows_ipaddrchangemonitor</tag>
        <p>Now only available to be set in Windows builds.
 
@@ -524,7 +527,6 @@ This section gives an account of those changes in three categories:
 
        <tag>logformat</tag>
        <p><em>%oa</em> tag not yet ported from 2.7
-       <p><em>%sn</em> tag not yet ported from 2.7
 
        <tag>max_filedescriptors</tag>
        <p>Not yet ported from 2.7
index 301ae8f2f80b9ecf8e40066be0363c9b1be3aeb7..d71baee48f82cbcae16d364a823c9556bec756cc 100644 (file)
@@ -397,6 +397,8 @@ typedef enum {
     LFT_IO_SIZE_TOTAL,
     LFT_EXT_LOG,
 
+    LFT_SEQUENCE_NUMBER,
+
 #if USE_ADAPTATION
     LTF_ADAPTATION_SUM_XACT_TIMES,
     LTF_ADAPTATION_ALL_XACT_TIMES,
@@ -547,6 +549,7 @@ struct logformat_token_table_entry logformat_token_table[] = {
     {"et", LFT_TAG},
     {"st", LFT_IO_SIZE_TOTAL},
     {"ea", LFT_EXT_LOG},
+    {"sn", LFT_SEQUENCE_NUMBER},
 
     {"%", LFT_PERCENT},
 
@@ -1123,6 +1126,11 @@ accessLogCustom(AccessLogEntry * al, customlog * log)
 
             break;
 
+        case LFT_SEQUENCE_NUMBER:
+            outoff = logfile->sequence_number;
+            dooff = 1;
+            break;
+
         case LFT_PERCENT:
             out = "%";
 
index a5291db5574086169f4b819efa5ab4271cd67460..c27c9a29eec0ce6070b624799af94d167f35bcc5 100644 (file)
@@ -2400,6 +2400,7 @@ DOC_START
                <A      Server IP address or peer name
                la      Local IP address (http_port)
                lp      Local port number (http_port)
+               sn      Unique sequence number per log line entry
                ts      Seconds since epoch
                tu      subsecond time (milliseconds)
                tl      Local time. Optional strftime format argument
index 1db6d3985adaa382b864c057be42c6232cb714f5..d746170ac4395d006722f73353e6b35e27bf42b3 100644 (file)
@@ -145,6 +145,8 @@ logfileOpen(const char *path, size_t bufsz, int fatal_flag)
     if (fatal_flag)
         lf->flags.fatal = 1;
 
+    lf->sequence_number = 0;
+
     return lf;
 }
 
@@ -218,6 +220,9 @@ logfileRotate(Logfile * lf)
 void
 logfileWrite(Logfile * lf, void *buf, size_t len)
 {
+   /* AYJ: this write gets called once per line? Squid-2 did it in lineEnd which we dont have. */
+   lf->sequence_number++;
+
 #if HAVE_SYSLOG
 
     if (lf->flags.syslog) {
index 9fa48e1bcfe23af6738b4c95f8bce6f8224b50e5..e80fc29f736c2569c995c4244bad4bfac24dfbb7 100644 (file)
@@ -1303,6 +1303,8 @@ struct _Logfile {
     } flags;
 
     int syslog_priority;
+
+    int64_t sequence_number;  ///< Unique sequence number per log line.
 };
 
 class logformat_token;