Commit 2b1b701b authored by Tollef Fog Heen's avatar Tollef Fog Heen

Add "log" command to VCL

This allows logging to varnishlog with the VCL_Log tag.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5016 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 50ded9b9
......@@ -947,6 +947,20 @@ VRT_synth_page(struct sess *sp, unsigned flags, const char *str, ...)
/*--------------------------------------------------------------------*/
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, ...)
{
......
......@@ -117,3 +117,7 @@ varnish v1 -badvcl {
sub vcl_error { synthetic if "foo"; }
}
varnish v1 -vcl {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { log "FOO"; }
}
......@@ -96,3 +96,4 @@ SLTM(ESI_xmlerror)
SLTM(Hash)
SLTM(Backend_health)
SLTM(VCL_Log)
......@@ -486,6 +486,23 @@ parse_synthetic(struct vcc *tl)
Fb(tl, 0, " vrt_magic_string_end);\n");
}
/*--------------------------------------------------------------------*/
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);
......@@ -515,6 +532,7 @@ static struct action_table {
{ "set", parse_set },
{ "synthetic", parse_synthetic },
{ "unset", parse_unset },
{ "log", parse_log },
{ NULL, NULL }
};
......
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