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 { ...@@ -20,7 +20,7 @@ varnish v1 -vcl+backend {
set resp.http.who = debug.author(phk); set resp.http.who = debug.author(phk);
debug.test_priv_call(); debug.test_priv_call();
debug.test_priv_vcl(); debug.test_priv_vcl();
std.log("VCL initiated log"); std.log("VCL" + " initiated " + "log");
std.syslog(8 + 7, "Somebody runs varnishtest"); std.syslog(8 + 7, "Somebody runs varnishtest");
debug.rot52(resp); debug.rot52(resp);
} }
...@@ -36,6 +36,20 @@ client c1 { ...@@ -36,6 +36,20 @@ client c1 {
expect resp.http.encrypted == "ROT52" expect resp.http.encrypted == "ROT52"
} -run } -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:} { varnish v1 -errvcl {Wrong enum value. Expected one of:} {
import debug; import debug;
sub vcl_deliver { sub vcl_deliver {
......
...@@ -9,16 +9,26 @@ varnish v1 -vcl+backend { ...@@ -9,16 +9,26 @@ varnish v1 -vcl+backend {
import std; import std;
sub vcl_init { sub vcl_init {
std.log("init"); std.log("init" + " one " + "two");
std.syslog(8 + 7, "init"); std.syslog(8 + 7, "init");
} }
sub vcl_fini { sub vcl_fini {
std.log("fini"); std.log("fini" + " one " + "two");
std.syslog(8 + 7, "fini"); std.syslog(8 + 7, "fini");
} }
} -start } -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 -vcl+backend { }
varnish v1 -cliok "vcl.discard vcl1" varnish v1 -cliok "vcl.discard vcl1"
logexpect l1 -wait
...@@ -133,27 +133,31 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi) ...@@ -133,27 +133,31 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi)
} }
VCL_VOID __match_proto__(td_std_log) 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; unsigned u;
va_list ap; va_list ap;
txt t;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
va_start(ap, fmt); WS_Assert(ctx->ws);
if (ctx->vsl != NULL) {
u = WS_Reserve(ctx->ws, 0);
t.b = ctx->ws->f; u = WS_Reserve(ctx->ws, 0);
t.e = VRT_StringList(ctx->ws->f, u, fmt, ap); t.b = ctx->ws->f;
if (t.e != NULL) { va_start(ap, s);
assert(t.e > t.b); t.e = VRT_StringList(ctx->ws->f, u, s, ap);
t.e--;
VSLbt(ctx->vsl, SLT_VCL_Log, t);
}
WS_Release(ctx->ws, 0);
} else
VSLv(SLT_VCL_Log, 0, fmt, ap);
va_end(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) 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