Commit 7d496cc5 authored by Geoff Simmons's avatar Geoff Simmons

add field selector for %{tag}x formatter

parent f23a3952
This diff is collapsed.
......@@ -34,6 +34,7 @@
typedef struct arg_t {
char *name;
enum VSL_tag_e tag;
int fld;
} arg_t;
typedef void formatter_f(const tx_t *tx, const arg_t *args, char **s,
......
......@@ -12,7 +12,7 @@ rm -f $LOG $OUT
../varnishevent -f varnishevent.conf -r sw-doc.log -w $OUT -v
CKSUM=$( cksum $OUT )
if [ "$CKSUM" != "4178357783 21920698 $OUT" ]; then
if [ "$CKSUM" != "4053530460 22327728 $OUT" ]; then
echo "ERROR: Regression test log output incorrect cksum: $CKSUM"
exit 1
fi
......
......@@ -1257,6 +1257,7 @@ static const char
set_record_data(&rec, &chunk, "no backend connection", SLT_FetchError);
args.tag = SLT_FetchError;
args.fld = -1;
format_SLT(&tx, &args, &str, &len);
MASSERT(strncmp(str, "no backend connection", 21) == 0);
MASSERT(len == 21);
......@@ -1292,6 +1293,49 @@ static const char
MASSERT(strncmp(str, substr, strlen(substr)) == 0);
MASSERT(len == strlen(substr));
/* field selector */
set_record_data(&rec, &chunk, TS_RESP_PAYLOAD, SLT_Timestamp);
args.name = NULL;
args.fld = 0;
format_SLT(&tx, &args, &str, &len);
MASSERT(strncmp(str, "Resp:", 5) == 0);
MASSERT(len == 5);
/* header and field selector */
set_record_data(&rec, &chunk, TS_RESP_PAYLOAD, SLT_Timestamp);
args.name = strdup("Resp");
format_SLT(&tx, &args, &str, &len);
MASSERT(strncmp(str, substr, len) == 0);
MASSERT(len == strlen("1427799478.166798"));
/* header not found */
set_record_data(&rec, &chunk, TS_RESP_PAYLOAD, SLT_Timestamp);
args.name = strdup("Foo");
args.fld = -1;
str = NULL;
len = 0;
format_SLT(&tx, &args, &str, &len);
MAZ(str);
MAZ(len);
/* field not found */
set_record_data(&rec, &chunk, TS_RESP_PAYLOAD, SLT_Timestamp);
args.name = NULL;
args.fld = 4;
str = NULL;
len = 0;
format_SLT(&tx, &args, &str, &len);
MAZ(len);
/* header field not found */
set_record_data(&rec, &chunk, TS_RESP_PAYLOAD, SLT_Timestamp);
args.name = strdup("Resp");
args.fld = 3;
str = NULL;
len = 0;
format_SLT(&tx, &args, &str, &len);
MAZ(len);
return NULL;
}
......@@ -1388,7 +1432,8 @@ static const char
#define FULL_CLIENT_FMT "%b %d %D %H %h %I %{Foo}i %{Bar}o %l %m %O %q %r %s "\
"%t %T %{%F-%T.%i}t %U %u %{Varnish:time_firstbyte}x "\
"%{Varnish:hitmiss}x %{Varnish:handling}x %{VCL_Log:baz}x "\
"%{tag:VCL_acl}x %{tag:Debug}x %{tag:Timestamp:Req}x"
"%{tag:VCL_acl}x %{tag:Debug}x %{tag:Timestamp:Req}x "\
"%{tag:ReqAcct[0]}x %{tag:Timestamp:Resp[2]}x"
strcpy(config.cformat, FULL_CLIENT_FMT);
status = FMT_Init(err);
VMASSERT(status == 0, "FMT_Init: %s", err);
......@@ -1435,7 +1480,7 @@ static const char
"http://bazquux.com/foo?bar=baz&quux=wilco HTTP/1.1 200 "\
"[%d/%b/%Y:%T %z] 0 %F-%T.529143 /foo varnish 0.000166 hit hit "\
"logload MATCH ACL \"10.0.0.0\"/8 \"foo\\0\\377 bar\" " \
"1429213569.602005 0.000000 0.000000\n"
"1429213569.602005 0.000000 0.000000 60 0.000125\n"
tm = localtime(&t);
MAN(strftime(strftime_s, BUFSIZ, EXP_FULL_CLIENT_OUTPUT, tm));
VMASSERT(strcmp(VSB_data(os), strftime_s) == 0, "'%s' != '%s'",
......@@ -1447,7 +1492,8 @@ static const char
#define FULL_BACKEND_FMT "%b %d %D %H %h %I %{Foo}i %{Bar}o %l %m %O %q %r %s "\
"%t %T %{%F-%T.%i}t %U %u %{Varnish:time_firstbyte}x %{VCL_Log:baz}x "\
"%{tag:Fetch_Body}x %{tag:Debug}x %{tag:Timestamp:Bereq}x"
"%{tag:Fetch_Body}x %{tag:Debug}x %{tag:Timestamp:Bereq}x "\
"%{tag:BereqAcct[5]}x %{tag:Timestamp:Bereq[1]}x"
strcpy(config.bformat, FULL_BACKEND_FMT);
config.cformat[0] = '\0';
status = FMT_Init(err);
......@@ -1500,7 +1546,7 @@ static const char
"http://bazquux.com/foo?bar=baz&quux=wilco HTTP/1.1 200 "\
"[%d/%b/%Y:%T %z] 0 %F-%T.529143 /foo varnish 0.002837 logload "\
"2 chunked stream \"foo\\0\\377 bar\" "\
"1429210777.728290 0.000048 0.000048\n"
"1429210777.728290 0.000048 0.000048 283 0.000048\n"
tm = localtime(&t);
MAN(strftime(strftime_s, BUFSIZ, EXP_FULL_BACKEND_OUTPUT, tm));
VMASSERT(strcmp(VSB_data(os), strftime_s) == 0, "'%s' != '%s'",
......
......@@ -2,8 +2,8 @@
monitor.interval = 0
cformat=%b %d %D %H %h %I %{Host}i %{Connection}i %{User-Agent}i %{X-Forwarded-For}i %{Accept-Ranges}o %{Age}o %{Connection}o %{Content-Encoding}o %{Content-Length}o %{Content-Type}o %{Date}o %{Last-Modified}o %{Server}o %{Transfer-Encoding}o %{Via}o %{X-Varnish}o %l %m %O %q %r %s %t %{%F-%T}t %U %u %{Varnish:time_firstbyte}x %{Varnish:hitmiss}x %{Varnish:handling}x %{tag:Begin}x %{tag:Debug}x %{tag:End}x %{tag:Gzip}x %{tag:Hit}x %{tag:Length}x %{tag:Link}x %{tag:ReqAcct}x %{tag:ReqStart}x %{tag:RespProtocol}x %{tag:ReqMethod}x %{tag:ReqURL}x %{tag:ReqProtocol}x %{tag:RespReason}x %{tag:RespStatus}x %{tag:Timestamp:Req}x
cformat=%b %d %D %H %h %I %{Host}i %{Connection}i %{User-Agent}i %{X-Forwarded-For}i %{Accept-Ranges}o %{Age}o %{Connection}o %{Content-Encoding}o %{Content-Length}o %{Content-Type}o %{Date}o %{Last-Modified}o %{Server}o %{Transfer-Encoding}o %{Via}o %{X-Varnish}o %l %m %O %q %r %s %t %{%F-%T}t %U %u %{Varnish:time_firstbyte}x %{Varnish:hitmiss}x %{Varnish:handling}x %{tag:Begin}x %{tag:Debug}x %{tag:End}x %{tag:Gzip}x %{tag:Hit}x %{tag:Length}x %{tag:Link}x %{tag:ReqAcct}x %{tag:ReqStart}x %{tag:RespProtocol}x %{tag:ReqMethod}x %{tag:ReqURL}x %{tag:ReqProtocol}x %{tag:RespReason}x %{tag:RespStatus}x %{tag:Timestamp:Req}x %{tag:ReqAcct[5]}x %{tag:Timestamp:Req[2]}x
bformat=%b %d %D %H %h %I %{Accept-Encoding}i %{Host}i %{User-Agent}i %{X-Forwarded-For}i %{X-Varnish}i %{Accept-Ranges}o %{Connection}o %{Content-Encoding}o %{Content-Length}o %{Content-Type}o %{Date}o %{ETag}o %{Last-Modified}o %{Server}o %{Transfer-Encoding}o %{Vary}o %l %m %O %q %r %s %t %{%F-%T}t %U %u %{Varnish:time_firstbyte}x %{tag:Backend}x %{tag:BackendOpen}x %{tag:BackendClose}x %{tag:BackendReuse}x %{tag:Begin}x %{tag:BereqAcct}x %{tag:Length}x %{tag:BerespProtocol}x %{tag:BerespReason}x %{tag:BerespStatus}x %{tag:BereqProtocol}x %{tag:BereqMethod}x %{tag:BereqURL}x %{tag:Debug}x %{tag:End}x %{tag:Timestamp:Bereq}x
bformat=%b %d %D %H %h %I %{Accept-Encoding}i %{Host}i %{User-Agent}i %{X-Forwarded-For}i %{X-Varnish}i %{Accept-Ranges}o %{Connection}o %{Content-Encoding}o %{Content-Length}o %{Content-Type}o %{Date}o %{ETag}o %{Last-Modified}o %{Server}o %{Transfer-Encoding}o %{Vary}o %l %m %O %q %r %s %t %{%F-%T}t %U %u %{Varnish:time_firstbyte}x %{tag:Backend}x %{tag:BackendOpen}x %{tag:BackendClose}x %{tag:BackendReuse}x %{tag:Begin}x %{tag:BereqAcct}x %{tag:Length}x %{tag:BerespProtocol}x %{tag:BerespReason}x %{tag:BerespStatus}x %{tag:BereqProtocol}x %{tag:BereqMethod}x %{tag:BereqURL}x %{tag:Debug}x %{tag:End}x %{tag:Timestamp:Bereq}x %{tag:BereqAcct[5]}x %{tag:Timestamp:Bereq[2]}x
log.file = test.log
......@@ -11,7 +11,7 @@ echo "... -g vxid"
CKSUM=$( ../varnishevent -g vxid -r sw-doc.log -f varnishevent.conf | cksum)
# Same as default (no -g arg)
if [ "$CKSUM" != '2669898744 21920736' ]; then
if [ "$CKSUM" != '2110242182 22327766' ]; then
echo "ERROR: -g vxid unexpected cksum: $CKSUM"
exit 1
fi
......@@ -19,7 +19,7 @@ fi
echo "... -g request"
CKSUM=$( ../varnishevent -g request -r sw-doc.log -f varnishevent.conf | cksum)
if [ "$CKSUM" != '1458016223 21920736' ]; then
if [ "$CKSUM" != '1162377575 22327766' ]; then
echo "ERROR: -g request unexpected cksum: $CKSUM"
exit 1
fi
......
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