r2591 - trunk/varnish-cache/lib/libvarnishapi

des at projects.linpro.no des at projects.linpro.no
Tue Mar 11 10:48:28 CET 2008


Author: des
Date: 2008-03-11 10:48:27 +0100 (Tue, 11 Mar 2008)
New Revision: 2591

Modified:
   trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
VSL_H_Print() prints a 'b' in the third column for backend-related log
entries, a 'c' for client-related log entries, and a ' ' for everything
else (CLI Ping for instance).  This makes it hard to process logs with
awk or similar tools, since the number of columns varies.  Therefore,
change the character used for non-backend-or-client log entries to '-'.


Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2008-03-10 21:21:15 UTC (rev 2590)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2008-03-11 09:48:27 UTC (rev 2591)
@@ -363,11 +363,15 @@
 VSL_H_Print(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
 {
 	FILE *fo = priv;
+	int type;
 
 	assert(fo != NULL);
+
+	type = (spec & VSL_S_CLIENT) ? 'c' :
+	    (spec & VSL_S_BACKEND) ? 'b' : '-';
+
 	if (tag == SLT_Debug) {
-		fprintf(fo, "%5d %-12s %c \"", fd, VSL_tags[tag],
-		    ((spec & VSL_S_CLIENT) ? 'c' : (spec & VSL_S_BACKEND) ? 'b' : ' '));
+		fprintf(fo, "%5d %-12s %c \"", fd, VSL_tags[tag], type);
 		while (len-- > 0) {
 			if (*ptr >= ' ' && *ptr <= '~')
 				fprintf(fo, "%c", *ptr);
@@ -378,10 +382,7 @@
 		fprintf(fo, "\"\n");
 		return (0);
 	}
-	fprintf(fo, "%5d %-12s %c %.*s\n",
-	    fd, VSL_tags[tag],
-	    ((spec & VSL_S_CLIENT) ? 'c' : (spec & VSL_S_BACKEND) ? 'b' : ' '),
-	    len, ptr);
+	fprintf(fo, "%5d %-12s %c %.*s\n", fd, VSL_tags[tag], type, len, ptr);
 	return (0);
 }
 




More information about the varnish-commit mailing list