[master] edd955f fix std.log() to behave the same in ini/fini and the rest, now that we got a ws
Nils Goroll
nils.goroll at uplex.de
Wed Sep 7 10:52:13 CEST 2016
commit edd955fcafbd1bfa6a64dee6c98d61cf12bb89d8
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Sep 6 12:33:03 2016 +0200
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
diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc
index b4d29c8..6028b0b 100644
--- a/bin/varnishtest/tests/m00000.vtc
+++ b/bin/varnishtest/tests/m00000.vtc
@@ -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 {
diff --git a/bin/varnishtest/tests/r01924.vtc b/bin/varnishtest/tests/r01924.vtc
index d553124..3ea78eb 100644
--- a/bin/varnishtest/tests/r01924.vtc
+++ b/bin/varnishtest/tests/r01924.vtc
@@ -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
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 7f0b35d..a76fa78 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -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)
More information about the varnish-commit
mailing list