Hi,
We've talked about having a «log» action in VCL for the longest time,
so I implemented it. Patch attached. I'm not entirely happy about the
name of the shmlog tag, but I can live with VCL_Log.
Comments/ok to commit?
Patch attached.
--
Tollef Fog Heen
Varnish Software
t: +47 21 54 41 73
Index: varnish-cache/include/shmlog_tags.h
===================================================================
--- varnish-cache/include/shmlog_tags.h (revisjon 4787)
+++ varnish-cache/include/shmlog_tags.h (arbeidskopi)
@@ -96,3 +96,5 @@
SLTM(Hash)
SLTM(Backend_health)
+
+SLTM(VCL_Log)
Index: varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- varnish-cache/lib/libvcl/vcc_action.c (revisjon 4787)
+++ varnish-cache/lib/libvcl/vcc_action.c (arbeidskopi)
@@ -476,7 +476,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 tokenlist *tl);
static struct action_table {
@@ -503,6 +520,7 @@
{ "set", parse_set },
{ "synthetic", parse_synthetic },
{ "unset", parse_unset },
+ { "log", parse_log },
{ NULL, NULL }
};
Index: varnish-cache/bin/varnishtest/tests/v00018.vtc
===================================================================
--- varnish-cache/bin/varnishtest/tests/v00018.vtc (revisjon 4787)
+++ varnish-cache/bin/varnishtest/tests/v00018.vtc (arbeidskopi)
@@ -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"; }
+}
Index: varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- varnish-cache/bin/varnishd/cache_vrt.c (revisjon 4787)
+++ varnish-cache/bin/varnishd/cache_vrt.c (arbeidskopi)
@@ -937,7 +937,22 @@
/*--------------------------------------------------------------------*/
+/*lint -e{818} sp could be const */
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;
_______________________________________________
varnish-dev mailing list
[email protected]
http://lists.varnish-cache.org/mailman/listinfo/varnish-dev