[3.0] 07d488c varnishlog: if -m given, but no -c and -b, assume both

Tollef Fog Heen tfheen at varnish-cache.org
Mon Apr 22 13:27:01 CEST 2013


commit 07d488cb96c703dd7c0ccf7049448c6291f1f0cf
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Mon Feb 4 14:17:50 2013 +0100

    varnishlog: if -m given, but no -c and -b, assume both
    
    If we don't add -c and -b in there, varnishlog will print all
    transactions that aren't associated with a session.  That is likely to
    not be what the user wants.
    
    Fixes: #1071

diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c
index c7749cb..d15c485 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -48,7 +48,7 @@
 #include "vsl.h"
 #include "varnishapi.h"
 
-static int	b_flag, c_flag;
+static int	b_flag = 0, c_flag = 0;
 
 /* Ordering-----------------------------------------------------------*/
 
@@ -329,6 +329,16 @@ main(int argc, char * const *argv)
 		}
 	}
 
+	/* If we're matching, we want either -b or -c, apply both if
+	 * none are given.  This prevents spurious noise in the log
+	 * output. */
+	if (b_flag == 0 && c_flag == 0 && m_flag) {
+		b_flag = 1;
+		AN(VSL_Arg(vd, 'b', NULL));
+		c_flag = 1;
+		AN(VSL_Arg(vd, 'c', NULL));
+	}
+
 	if (O_flag && m_flag)
 		usage();
 



More information about the varnish-commit mailing list