Commit dba10578 authored by Geoff Simmons's avatar Geoff Simmons

varnishevent - added %r formatting

parent cc3bdc14
......@@ -252,6 +252,51 @@ FORMAT_q(backend, TxURL)
break;
#endif
#define FORMAT_r(dir, dx, hx) \
static void \
format_r_##dir(logline_t *ll, char *name, enum VSL_tag_e tag, \
char **s, size_t *len) \
{ \
(void) name; \
(void) tag; \
\
record_t *rec; \
\
rec = &TAG(ll, SLT_##dx##Request); \
if (rec->len) \
snprintf(scratch, rec->len+1, "%s", rec->data); \
else \
strcpy(scratch, "-"); \
strcat(scratch, " "); \
\
if ((rec = GET_HDR(ll, hx, "Host")) != NULL) { \
if (strncmp(rec->data, "http://", 7) != 0) \
strcat(scratch, "http://"); \
strncat(scratch, rec->data+6, rec->len-6); \
} \
else \
strcat(scratch, "http://localhost"); \
\
rec = &TAG(ll, SLT_##dx##URL); \
if (rec->len) \
strncat(scratch, rec->data, rec->len); \
else \
strcat(scratch, "-"); \
\
strcat(scratch, " "); \
rec = &TAG(ll, SLT_##dx##Protocol); \
if (rec->len) \
strncat(scratch, rec->data, rec->len); \
else \
strcat(scratch, "HTTP/1.0"); \
\
*s = scratch; \
*len = strlen(scratch); \
}
FORMAT_r(client, Rx, rx)
FORMAT_r(backend, Tx, tx)
FORMAT(client, s, TxStatus)
FORMAT(backend, s, RxStatus)
......@@ -568,6 +613,15 @@ compile_fmt(char *format, compiled_fmt_t *fmt, unsigned spec, char *err)
break;
#endif
case 'r':
ADD_FMT(spec, fmt, os, n, format_r, NULL, 0);
ADD_CB_TAG(spec, fmt->tags, RxRequest, TxRequest);
ADD_CB_TAG(spec, fmt->tags, RxHeader, TxHeader);
ADD_CB_TAG(spec, fmt->tags, RxURL, TxURL);
ADD_CB_TAG(spec, fmt->tags, RxProtocol, TxProtocol);
n++;
break;
case 's':
ADD_FMT(spec, fmt, os, n, format_s, NULL, 0);
ADD_CB_TAG(spec, fmt->tags, TxStatus, RxStatus);
......
......@@ -59,7 +59,7 @@
#endif
#define DEFAULT_CFORMAT \
"%h %l %t %U %s %b \"%{Referer}i\" \"%{User-agent}i\""
"%h %l %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""
#define ALT_CFORMAT \
"%{X-Forwarded-For}i %l %t %U %s %b \"%{Referer}i\" \"%{User-agent}i\""
......
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