]> err.no Git - varnish/commitdiff
put symbolic names on the tags
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 24 Mar 2006 09:14:06 +0000 (09:14 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 24 Mar 2006 09:14:06 +0000 (09:14 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@65 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishlog/varnishlog.c

index 12e5deb1f26419aa56eb096b241f533e90944dfa..cee28210e50e524451f2e653144dd9f400c1800e 100644 (file)
 
 #include <shmlog.h>
 
+/*
+ * It would be simpler to use sparse array initialization and put it
+ * directly in tagnames, but -pedantic gets in the way
+ */
+
+static struct tagnames {
+       enum shmlogtag  tag;
+       const char      *name;
+} stagnames[] = {
+#define SLTM(foo)      { SLT_##foo, #foo },
+#include "shmlog_tags.h"
+#undef SLTM
+       { SLT_ENDMARKER, NULL}
+};
+
+static const char *tagnames[256];
+
 static struct shmloghead *loghead;
 static unsigned char *logstart, *logend;
 
@@ -53,6 +70,9 @@ main(int argc, char **argv)
        logstart = (unsigned char *)loghead + loghead->start;
        logend = logstart + loghead->size;
 
+       for (i = 0; stagnames[i].tag != SLT_ENDMARKER; i++)
+               tagnames[stagnames[i].tag] = stagnames[i].name;
+
        while (1) {
                p = logstart;
                while (1) {
@@ -60,8 +80,9 @@ main(int argc, char **argv)
                                break;
                        while (*p == SLT_ENDMARKER) 
                                sleep(1);
-                       printf("%02x %02d %02x%02x <",
-                           p[0], p[1], p[2], p[3]);
+                       printf("%02x %02d %02x%02x %-12s <",
+                           p[0], p[1], p[2], p[3],
+                           tagnames[p[0]]);
                        if (p[1] > 0)
                                fwrite(p + 4, p[1], 1, stdout);
                        printf(">\n");