]> err.no Git - varnish/commitdiff
Add -b[ackend] and -c[lient] generic options to logtailers
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 11 Jul 2006 11:36:14 +0000 (11:36 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Tue, 11 Jul 2006 11:36:14 +0000 (11:36 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@422 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/varnishapi.h
varnish-cache/lib/libvarnishapi/shmlog.c

index b57bb78acd6a8a44759d8744d3215fce1f60ff98..a8721e929599cef57f54bbdce3250803078aa096 100644 (file)
@@ -8,7 +8,7 @@
 #define V_DEAD __attribute__ ((noreturn))
 
 /* shmlog.c */
-#define VSL_ARGS       "r:i:x:CI:X:"
+#define VSL_ARGS       "bcr:i:x:CI:X:"
 struct VSL_data;
 struct VSL_data *VSL_New(void);
 int VSL_OpenLog(struct VSL_data *vd);
index ef5192849bb6eaf32672521e6dbadc7bb5aff072..28531ee7d7b6e23891ca6610b4c2b31512c56f9f 100644 (file)
@@ -24,9 +24,14 @@ struct VSL_data {
        FILE                    *fi;
        unsigned char           rbuf[4 + 255 + 1];
 
+       int                     b_opt;
+       int                     c_opt;
+
        int                     ix_opt;
        unsigned char           supr[256];
 
+       unsigned char           dir[65536];
+
        int                     regflags;
        regex_t                 *regincl;
        regex_t                 *regexcl;
@@ -39,6 +44,7 @@ struct VSL_data {
 static int vsl_fd;
 static struct shmloghead *vsl_lh;
 
+
 /*--------------------------------------------------------------------*/
 
 const char *VSL_tags[256] = {
@@ -102,6 +108,9 @@ int
 VSL_OpenLog(struct VSL_data *vd)
 {
 
+       if (!vd->b_opt && !vd->c_opt)
+               vd->b_opt = vd->c_opt = 1;
+
        if (vd->fi != NULL)
                return (0);
 
@@ -155,14 +164,30 @@ VSL_NextLog(struct VSL_data *vd)
 {
        unsigned char *p;
        regmatch_t rm;
+       unsigned u;
        int i;
 
        while (1) {
                p = vsl_nextlog(vd);
                if (p == NULL)
                        return (p);
+               u = (p[2] << 8) | p[3];
+               switch(p[0]) {
+               case SLT_SessionOpen:
+                       vd->dir[u] = 1;
+                       break;
+               case SLT_BackendOpen:
+                       vd->dir[u] = 2;
+                       break;
+               default:
+                       break;
+               }
                if (vd->supr[p[0]]) 
                        continue;
+               if (vd->b_opt && vd->dir[u] == 1)
+                       continue;
+               if (vd->c_opt && vd->dir[u] == 2)
+                       continue;
                if (vd->regincl != NULL) {
                        rm.rm_so = 0;
                        rm.rm_eo = p[1];
@@ -285,6 +310,8 @@ int
 VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
 {
        switch (arg) {
+       case 'b': vd->b_opt = !vd->b_opt; return (1);
+       case 'c': vd->c_opt = !vd->c_opt; return (1);
        case 'i': case 'x': return (vsl_ix_arg(vd, opt, arg));
        case 'r': return (vsl_r_arg(vd, opt));
        case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg));