Commit 8bf0a33a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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

parent 7e14355f
...@@ -419,7 +419,7 @@ Examples:: ...@@ -419,7 +419,7 @@ Examples::
LOGGING functions 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 Logs the string *s* to the shared memory log, using :ref:`vsl(7)` tag
``SLT_VCL_Log``. ``SLT_VCL_Log``.
...@@ -428,7 +428,7 @@ Example:: ...@@ -428,7 +428,7 @@ Example::
std.log("Something fishy is going on with the vhost " + req.http.host); 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 Logs the string *s* to syslog tagged with *priority*. *priority* is
formed by ORing the facility and level values. See your system's formed by ORing the facility and level values. See your system's
......
...@@ -129,45 +129,33 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi) ...@@ -129,45 +129,33 @@ vmod_random(VRT_CTX, VCL_REAL lo, VCL_REAL hi)
} }
VCL_VOID v_matchproto_(td_std_log) VCL_VOID v_matchproto_(td_std_log)
vmod_log(VRT_CTX, const char *fmt, ...) vmod_log(VRT_CTX, VCL_STRANDS s)
{ {
const char *p; const char *p;
va_list ap;
uintptr_t sn; uintptr_t sn;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
sn = WS_Snapshot(ctx->ws); sn = WS_Snapshot(ctx->ws);
va_start(ap, fmt); p = VRT_StrandsWS(ctx->ws, NULL, s);
p = VRT_String(ctx->ws, NULL, fmt, ap); if (p != NULL) {
va_end(ap);
if (p == NULL) {
WS_Reset(ctx->ws, sn);
WS_MarkOverflow(ctx->ws);
return;
}
AN(p);
if (ctx->vsl != NULL) if (ctx->vsl != NULL)
VSLb(ctx->vsl, SLT_VCL_Log, "%s", p); VSLb(ctx->vsl, SLT_VCL_Log, "%s", p);
else else
VSL(SLT_VCL_Log, 0, "%s", p); VSL(SLT_VCL_Log, 0, "%s", p);
}
WS_Reset(ctx->ws, sn); WS_Reset(ctx->ws, sn);
} }
/* XXX use vsyslog() ? */ /* XXX use vsyslog() ? */
VCL_VOID v_matchproto_(td_std_syslog) 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; const char *p;
va_list ap;
uintptr_t sn; uintptr_t sn;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
sn = WS_Snapshot(ctx->ws); sn = WS_Snapshot(ctx->ws);
va_start(ap, fmt); p = VRT_StrandsWS(ctx->ws, NULL, s);
p = VRT_String(ctx->ws, NULL, fmt, ap);
va_end(ap);
if (p != NULL) if (p != NULL)
syslog((int)fac, "%s", p); syslog((int)fac, "%s", p);
WS_Reset(ctx->ws, sn); WS_Reset(ctx->ws, sn);
......
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