Commit 2b474455 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp
parents 6e4e013f e9e02a49
......@@ -108,6 +108,7 @@ static struct logline {
uint64_t bitmap; /* Bitmap for regex matches */
VTAILQ_HEAD(, hdr) req_headers; /* Request headers */
VTAILQ_HEAD(, hdr) resp_headers; /* Response headers */
VTAILQ_HEAD(, hdr) vcl_log; /* VLC_Log entries */
} **ll;
struct VSM_data *vd;
......@@ -219,6 +220,19 @@ resp_header(struct logline *l, const char *name)
return NULL;
}
static char *
vcl_log(struct logline *l, const char *name)
{
struct hdr *h;
VTAILQ_FOREACH(h, &l->vcl_log, list) {
if (strcasecmp(h->key, name) == 0) {
return h->value;
break;
}
}
return NULL;
}
static void
clean_logline(struct logline *lp)
{
......@@ -245,6 +259,12 @@ clean_logline(struct logline *lp)
freez(h->value);
freez(h);
}
VTAILQ_FOREACH_SAFE(h, &lp->vcl_log, list, h2) {
VTAILQ_REMOVE(&lp->vcl_log, h, list);
freez(h->key);
freez(h->value);
freez(h);
}
#undef freez
memset(lp, 0, sizeof *lp);
}
......@@ -465,6 +485,25 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
}
break;
case SLT_VCL_Log:
if(!lp->active)
break;
split = strchr(ptr, ':');
if (split == NULL)
break;
struct hdr *h;
h = malloc(sizeof(struct hdr));
AN(h);
AN(split);
h->key = trimline(ptr, split);
h->value = trimline(split+1, end);
VTAILQ_INSERT_HEAD(&lp->vcl_log, h, list);
break;
case SLT_VCL_call:
if(!lp->active)
break;
......@@ -590,6 +629,14 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
for (p = format; *p != '\0'; p++) {
/* allow the most essential escape sequences in format. */
if (*p == '\\') {
p++;
if (*p == 't') VSB_putc(os, '\t');
if (*p == 'n') VSB_putc(os, '\n');
continue;
}
if (*p != '%') {
VSB_putc(os, *p);
continue;
......@@ -718,6 +765,14 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
VSB_cat(os, (lp->df_handling ? lp->df_handling : "-"));
p = tmp;
break;
} else if (strncmp(fname, "VCL_Log:", 8) == 0) {
// support pulling entries logged with std.log() into output.
// Format: %{VCL_Log:keyname}x
// Logging: std.log("keyname:value")
h = vcl_log(lp, fname+8);
VSB_cat(os, h ? h : "-");
p = tmp;
break;
}
default:
fprintf(stderr, "Unknown format starting at: %s\n", --p);
......
......@@ -9,10 +9,10 @@ question answered conclusively long time ago, but once you try to
be efficient, things get hairy fast.
One of the features of Varnish we are very fundamental about, is the
ability to have multiple VCL's loaded at the same time, and to switch
ability to have multiple VCLs loaded at the same time, and to switch
between them instantly and seamlessly.
So Imagine you have 1000 backends in your VCL, not an unreasonable
So imagine you have 1000 backends in your VCL, not an unreasonable
number, each configured with health-polling.
Now you fiddle your vcl_recv{} a bit and load the VCL again, but
......@@ -25,7 +25,7 @@ be up to date the instant we switch to the other VCL.
This basically means that either all VCLs poll all their backends,
or they must share, somehow.
We can dismiss the all VCL's poll all their backends scenario,
We can dismiss the all VCLs poll all their backends scenario,
because it scales truly horribly, and would pummel backends with
probes if people forget to vcl.discard their old dusty VCLs.
......@@ -39,7 +39,7 @@ It would be truly stupid to close 100 ready and usable connections to
a backend, and open 100 other, just because we switch to a different
VCL that has an identical backend definition.
But what is an identical backend definition in this context ?
But what is an identical backend definition in this context?
It is important to remember that we are not talking physical
backends: For instance, there is nothing preventing a VCL for
......@@ -48,7 +48,7 @@ backends.
The most obvious thing to do, is to use the VCL name of the backend
as identifier, but that is not enough. We can have two different
VCL's where backend "b1" points at two different physical machines,
VCLs where backend "b1" points at two different physical machines,
for instance when we migrate or upgrade the backend.
The identity of the state than can be shared is therefore the triplet:
......@@ -78,11 +78,11 @@ is a wildcard-ish scheme, where you can write things like::
b1() # All backends named b1
b1(127.0.0.1) # All b1's on Ipv4 lookback
b1(127.0.0.1) # All b1s on IPv4 lookback
b1(:8080) # All b1's on port 8080, (IPv4 or IPv6)
b1(:8080) # All b1s on port 8080, (IPv4 or IPv6)
b1(192.168.60.1,192.168.60.2) # All b1's on one of those addresses.
b1(192.168.60.1,192.168.60.2) # All b1s on one of those addresses.
(Input very much welcome)
......@@ -112,7 +112,7 @@ the backend gets retired anyway.
We should either park a thread on each backend, or have a poller thread
which throws jobs into the work-pool as the backends needs polled.
The patternmatching is confined to CLI and possibly libvarnishapi
The pattern matching is confined to CLI and possibly libvarnishapi
I think this will work,
......
......@@ -54,6 +54,8 @@ The following options are available:
%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i"
Escape sequences \\n and \\t are supported.
Supported formatters are:
%b
......@@ -116,6 +118,10 @@ The following options are available:
Varnish:handling
How the request was handled, whether it was a
cache hit, miss, pass, pipe or error.
VCL_Log:key
Output value set by std.log("key=value") in VCL.
-m tag:regex only list records where tag matches regex. Multiple
-m options are AND-ed together.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment