]> err.no Git - varnish/commitdiff
Strvis(3) debug data.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 7 Jul 2006 06:27:32 +0000 (06:27 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 7 Jul 2006 06:27:32 +0000 (06:27 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@365 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishlog/varnishlog.c

index bfbed74ab34307ae01c06fa80a2f1ffffd428ff9..fc76c24d6a35958f95f01abecef512f7ec8d85f5 100644 (file)
@@ -11,6 +11,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include <sbuf.h>
+#include <vis.h>
 
 #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();