From: phk Date: Fri, 7 Jul 2006 06:27:32 +0000 (+0000) Subject: Strvis(3) debug data. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aeb2d05245e484f3c719c5a20c1737b2a290f48b;p=varnish Strvis(3) debug data. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@365 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishlog/varnishlog.c b/varnish-cache/bin/varnishlog/varnishlog.c index bfbed74a..fc76c24d 100644 --- a/varnish-cache/bin/varnishlog/varnishlog.c +++ b/varnish-cache/bin/varnishlog/varnishlog.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "shmlog.h" #include "varnishapi.h" @@ -32,6 +33,18 @@ static struct tagnames { static const char *tagnames[256]; +static char * +vis_it(unsigned char *p) +{ + static char visbuf[255*4 + 3 + 1]; + + strcpy(visbuf, " ["); + strvisx(visbuf + 2, p + 4, p[1], + VIS_OCTAL | VIS_TAB | VIS_NL); + strcat(visbuf, "]"); + return (visbuf); +} + /* Ordering-----------------------------------------------------------*/ static struct sbuf *ob[65536]; @@ -83,6 +96,13 @@ order(unsigned char *p) sbuf_cat(ob[u], ">\n"); } break; + case SLT_Debug: + sbuf_printf(ob[u], "%02x %3d %4d %-12s", + p[0], p[1], u, tagnames[p[0]]); + if (p[1] > 0) + sbuf_cat(ob[u], vis_it(p)); + sbuf_cat(ob[u], "\n"); + break; default: sbuf_printf(ob[u], "%02x %3d %4d %-12s", p[0], p[1], u, tagnames[p[0]]); @@ -227,11 +247,20 @@ main(int argc, char **argv) continue; } u = (p[2] << 8) | p[3]; - printf("%02x %3d %4d %-12s <", + printf("%02x %3d %4d %-12s", p[0], p[1], u, tagnames[p[0]]); - if (p[1] > 0) - fwrite(p + 4, p[1], 1, stdout); - printf(">\n"); + + if (p[1] > 0) { + if (p[0] != SLT_Debug) { + printf(" <"); + fwrite(p + 4, p[1], 1, stdout); + printf(">"); + } else { + fputs(vis_it(p), stdout); + } + + } + printf("\n"); } if (o_flag) clean_order();