[master] a4f9ef9 Use a tag flag to mark binary log records

Martin Blix Grydeland martin at varnish-cache.org
Thu Oct 31 12:21:09 CET 2013


commit a4f9ef962707b896abf35984f6ace234d9479aed
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu Oct 31 12:15:36 2013 +0100

    Use a tag flag to mark binary log records

diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h
index a68e41f..8fb008e 100644
--- a/include/vapi/vsl.h
+++ b/include/vapi/vsl.h
@@ -111,6 +111,11 @@ extern const char *VSL_tags[SLT__MAX];
 	 * Tag to string array.  Contains NULL for invalid tags.
 	 */
 
+extern unsigned VSL_tagflags[SLT__MAX];
+	/*
+	 * Tag flags array.
+	 */
+
 int VSL_Name2Tag(const char *name, int l);
 	/*
 	 * Convert string to tag number (= enum VSL_tag_e). Name can be a
diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c
index 886f5bf..8375a2c 100644
--- a/lib/libvarnishapi/vsl.c
+++ b/lib/libvarnishapi/vsl.c
@@ -63,6 +63,12 @@ const char *VSL_tags[SLT__MAX] = {
 #  undef SLTM
 };
 
+unsigned VSL_tagflags[SLT__MAX] = {
+#  define SLTM(foo, flags, sdesc, ldesc)	[SLT_##foo] = flags,
+#  include "tbl/vsl_tags.h"
+#  undef SLTM
+};
+
 int
 vsl_diag(struct VSL_data *vsl, const char *fmt, ...)
 {
@@ -246,7 +252,7 @@ VSL_Print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
 	    'b' : '-';
 	data = VSL_CDATA(c->rec.ptr);
 
-	if (tag == SLT_Debug) {
+	if (VSL_tagflags[tag] & SLT_F_BINARY) {
 		VSL_PRINT(fo, "%10u %-14s %c \"", vxid, VSL_tags[tag], type);
 		while (len-- > 0) {
 			if (*data >= ' ' && *data <= '~')
@@ -279,7 +285,7 @@ VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo)
 	len = VSL_LEN(c->rec.ptr);
 	data = VSL_CDATA(c->rec.ptr);
 
-	if (tag == SLT_Debug) {
+	if (VSL_tagflags[tag] & SLT_F_BINARY) {
 		VSL_PRINT(fo, "%-14s \"", VSL_tags[tag]);
 		while (len-- > 0) {
 			if (*data >= ' ' && *data <= '~')



More information about the varnish-commit mailing list