[master] 8bf0a33ae Convert std.log() and std.syslog from STRING_LIST to STRANDS.

Poul-Henning Kamp phk at FreeBSD.org
Tue Jun 18 07:26:09 UTC 2019


commit 8bf0a33aee49e10b01dd9aea54a6c01e60bc85d5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jun 18 07:07:47 2019 +0000

    Convert std.log() and std.syslog from STRING_LIST to STRANDS.

diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc
index ee56f584e..a30d7809b 100644
--- a/lib/libvmod_std/vmod.vcc
+++ b/lib/libvmod_std/vmod.vcc
@@ -419,7 +419,7 @@ Examples::
 LOGGING functions
 =================
 
-$Function VOID log(STRING_LIST s)
+$Function VOID log(STRANDS s)
 
 Logs the string *s* to the shared memory log, using :ref:`vsl(7)` tag
 ``SLT_VCL_Log``.
@@ -428,7 +428,7 @@ Example::
 
 	std.log("Something fishy is going on with the vhost " + req.http.host);
 
-$Function VOID syslog(INT priority, STRING_LIST s)
+$Function VOID syslog(INT priority, STRANDS s)
 
 Logs the string *s* to syslog tagged with *priority*. *priority* is
 formed by ORing the facility and level values. See your system's
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 7d2871e57..d1b7411ec 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -129,45 +129,33 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi)
 }
 
 VCL_VOID v_matchproto_(td_std_log)
-vmod_log(VRT_CTX, const char *fmt, ...)
+vmod_log(VRT_CTX, VCL_STRANDS s)
 {
 	const char *p;
-	va_list ap;
 	uintptr_t sn;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	sn = WS_Snapshot(ctx->ws);
-	va_start(ap, fmt);
-	p = VRT_String(ctx->ws, NULL, fmt, ap);
-	va_end(ap);
-
-	if (p == NULL) {
-		WS_Reset(ctx->ws, sn);
-		WS_MarkOverflow(ctx->ws);
-		return;
+	p = VRT_StrandsWS(ctx->ws, NULL, s);
+	if (p != NULL) {
+		if (ctx->vsl != NULL)
+			VSLb(ctx->vsl, SLT_VCL_Log, "%s", p);
+		else
+			VSL(SLT_VCL_Log, 0, "%s", p);
 	}
-
-	AN(p);
-	if (ctx->vsl != NULL)
-		VSLb(ctx->vsl, SLT_VCL_Log, "%s", p);
-	else
-		VSL(SLT_VCL_Log, 0, "%s", p);
 	WS_Reset(ctx->ws, sn);
 }
 
 /* XXX use vsyslog() ? */
 VCL_VOID v_matchproto_(td_std_syslog)
-vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...)
+vmod_syslog(VRT_CTX, VCL_INT fac, VCL_STRANDS s)
 {
 	const char *p;
-	va_list ap;
 	uintptr_t sn;
 
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
 	sn = WS_Snapshot(ctx->ws);
-	va_start(ap, fmt);
-	p = VRT_String(ctx->ws, NULL, fmt, ap);
-	va_end(ap);
+	p = VRT_StrandsWS(ctx->ws, NULL, s);
 	if (p != NULL)
 		syslog((int)fac, "%s", p);
 	WS_Reset(ctx->ws, sn);


More information about the varnish-commit mailing list