r5016 - in trunk/varnish-cache: bin/varnishd bin/varnishtest/tests include lib/libvcl
tfheen at varnish-cache.org
tfheen at varnish-cache.org
Tue Jul 6 09:28:04 CEST 2010
Author: tfheen
Date: 2010-07-06 09:28:04 +0200 (Tue, 06 Jul 2010)
New Revision: 5016
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc
trunk/varnish-cache/include/vsl_tags.h
trunk/varnish-cache/lib/libvcl/vcc_action.c
Log:
Add "log" command to VCL
This allows logging to varnishlog with the VCL_Log tag.
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-07-06 07:25:51 UTC (rev 5015)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-07-06 07:28:04 UTC (rev 5016)
@@ -948,6 +948,20 @@
/*--------------------------------------------------------------------*/
void
+VRT_log(struct sess *sp, const char *str, ...)
+{
+ va_list ap;
+ char *b;
+
+ va_start(ap, str);
+ b = vrt_assemble_string(sp->http, NULL, str, ap);
+ va_end(ap);
+ WSP(sp, SLT_VCL_Log, "%s", b);
+}
+
+/*--------------------------------------------------------------------*/
+
+void
VRT_ban(struct sess *sp, char *cmds, ...)
{
char *a1, *a2, *a3;
Modified: trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc 2010-07-06 07:25:51 UTC (rev 5015)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00018.vtc 2010-07-06 07:28:04 UTC (rev 5016)
@@ -117,3 +117,7 @@
sub vcl_error { synthetic if "foo"; }
}
+varnish v1 -vcl {
+ backend b { .host = "127.0.0.1"; }
+ sub vcl_recv { log "FOO"; }
+}
Modified: trunk/varnish-cache/include/vsl_tags.h
===================================================================
--- trunk/varnish-cache/include/vsl_tags.h 2010-07-06 07:25:51 UTC (rev 5015)
+++ trunk/varnish-cache/include/vsl_tags.h 2010-07-06 07:28:04 UTC (rev 5016)
@@ -96,3 +96,4 @@
SLTM(Hash)
SLTM(Backend_health)
+SLTM(VCL_Log)
Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-07-06 07:25:51 UTC (rev 5015)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c 2010-07-06 07:28:04 UTC (rev 5016)
@@ -487,7 +487,24 @@
}
/*--------------------------------------------------------------------*/
+static void
+parse_log(struct tokenlist *tl)
+{
+ vcc_NextToken(tl);
+ Fb(tl, 1, "VRT_log(sp, ");
+ if (!vcc_StringVal(tl)) {
+ vcc_ExpectedStringval(tl);
+ return;
+ }
+ do
+ Fb(tl, 0, ", ");
+ while (vcc_StringVal(tl));
+ Fb(tl, 0, " vrt_magic_string_end);\n");
+}
+
+/*--------------------------------------------------------------------*/
+
typedef void action_f(struct vcc *tl);
static struct action_table {
@@ -515,6 +532,7 @@
{ "set", parse_set },
{ "synthetic", parse_synthetic },
{ "unset", parse_unset },
+ { "log", parse_log },
{ NULL, NULL }
};
More information about the varnish-commit
mailing list