[master] 78936f6 varnishlog: if -m given, but no -c and -b, assume both

Tollef Fog Heen tfheen at varnish-cache.org
Mon Feb 4 14:50:57 CET 2013


commit 78936f6460cb8d6dc61d93d828f51c42018e411f
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 07fef9b..270855f 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -49,7 +49,7 @@
 
 #include "compat/daemon.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