From 6f09df94ba4e52ad271947e035fb663f9c76a03d Mon Sep 17 00:00:00 2001 From: des Date: Tue, 11 Mar 2008 09:48:27 +0000 Subject: [PATCH] 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 '-'. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2591 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvarnishapi/shmlog.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/varnish-cache/lib/libvarnishapi/shmlog.c b/varnish-cache/lib/libvarnishapi/shmlog.c index 3dc4eb84..6b35d0eb 100644 --- a/varnish-cache/lib/libvarnishapi/shmlog.c +++ b/varnish-cache/lib/libvarnishapi/shmlog.c @@ -363,11 +363,15 @@ int 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 @@ VSL_H_Print(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned 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); } -- 2.39.5