Commit edd955fc authored by Nils Goroll's avatar Nils Goroll

fix std.log() to behave the same in ini/fini and the rest, now that we got a ws

Previously, std.log had printf-semantics for the case that there is no ctx->vsl.

Now, for all cases, it just prints the given STRING_LIST

Fixes the example given in #2063
parent c4c444ca
......@@ -20,7 +20,7 @@ varnish v1 -vcl+backend {
set resp.http.who = debug.author(phk);
debug.test_priv_call();
debug.test_priv_vcl();
std.log("VCL initiated log");
std.log("VCL" + " initiated " + "log");
std.syslog(8 + 7, "Somebody runs varnishtest");
debug.rot52(resp);
}
......@@ -36,6 +36,20 @@ client c1 {
expect resp.http.encrypted == "ROT52"
} -run
logexpect l1 -v v1 -g raw -d 1 {
expect * 1001 VCL_call {^DELIVER}
expect 0 = RespUnset {^foo: bAr}
expect 0 = RespHeader {^foo: BAR}
expect 0 = RespUnset {^bar: fOo}
expect 0 = RespHeader {^bar: foo}
expect 0 = RespHeader {^who: Poul-Henning}
expect 0 = VCL_Log {^VCL initiated log}
expect 0 = RespHeader {^Encrypted: ROT52}
expect 0 = VCL_return {^deliver}
} -start
logexpect l1 -wait
varnish v1 -errvcl {Wrong enum value. Expected one of:} {
import debug;
sub vcl_deliver {
......
......@@ -9,16 +9,26 @@ varnish v1 -vcl+backend {
import std;
sub vcl_init {
std.log("init");
std.log("init" + " one " + "two");
std.syslog(8 + 7, "init");
}
sub vcl_fini {
std.log("fini");
std.log("fini" + " one " + "two");
std.syslog(8 + 7, "fini");
}
} -start
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 0 = VCL_Log {^init one two}
expect * 0 CLI {^Rd vcl.discard}
expect 0 = VCL_Log {^fini one two}
} -start
varnish v1 -vcl+backend { }
varnish v1 -cliok "vcl.discard vcl1"
logexpect l1 -wait
......@@ -133,27 +133,31 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi)
}
VCL_VOID __match_proto__(td_std_log)
vmod_log(VRT_CTX, const char *fmt, ...)
vmod_log(VRT_CTX, const char *s, ...)
{
txt t;
unsigned u;
va_list ap;
txt t;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
va_start(ap, fmt);
if (ctx->vsl != NULL) {
u = WS_Reserve(ctx->ws, 0);
t.b = ctx->ws->f;
t.e = VRT_StringList(ctx->ws->f, u, fmt, ap);
if (t.e != NULL) {
assert(t.e > t.b);
t.e--;
VSLbt(ctx->vsl, SLT_VCL_Log, t);
}
WS_Release(ctx->ws, 0);
} else
VSLv(SLT_VCL_Log, 0, fmt, ap);
WS_Assert(ctx->ws);
u = WS_Reserve(ctx->ws, 0);
t.b = ctx->ws->f;
va_start(ap, s);
t.e = VRT_StringList(ctx->ws->f, u, s, ap);
va_end(ap);
if (t.e != NULL) {
assert(t.e > t.b);
t.e--;
if (ctx->vsl != NULL)
VSLbt(ctx->vsl, SLT_VCL_Log, t);
else
VSL(SLT_VCL_Log, 0, "%s", t.b);
}
WS_Release(ctx->ws, 0);
}
VCL_VOID __match_proto__(td_std_syslog)
......
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