Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
d5117f53
Commit
d5117f53
authored
Oct 31, 2011
by
Lasse Karstensen
Committed by
Tollef Fog Heen
Feb 28, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new format %{VCL_Log:foo}x which output key:value from std.log() in VCL
parent
d04a8fb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
0 deletions
+51
-0
varnishncsa.c
bin/varnishncsa/varnishncsa.c
+47
-0
varnishncsa.rst
doc/sphinx/reference/varnishncsa.rst
+4
-0
No files found.
bin/varnishncsa/varnishncsa.c
View file @
d5117f53
...
...
@@ -105,6 +105,7 @@ static struct logline {
uint64_t
bitmap
;
/* Bitmap for regex matches */
VTAILQ_HEAD
(,
hdr
)
req_headers
;
/* Request headers */
VTAILQ_HEAD
(,
hdr
)
resp_headers
;
/* Response headers */
VTAILQ_HEAD
(,
hdr
)
vcl_log
;
/* VLC_Log entries */
}
**
ll
;
struct
VSM_data
*
vd
;
...
...
@@ -216,6 +217,19 @@ resp_header(struct logline *l, const char *name)
return
NULL
;
}
static
char
*
vcl_log
(
struct
logline
*
l
,
const
char
*
name
)
{
struct
hdr
*
h
;
VTAILQ_FOREACH
(
h
,
&
l
->
vcl_log
,
list
)
{
if
(
strcasecmp
(
h
->
key
,
name
)
==
0
)
{
return
h
->
value
;
break
;
}
}
return
NULL
;
}
static
void
clean_logline
(
struct
logline
*
lp
)
{
...
...
@@ -242,6 +256,12 @@ clean_logline(struct logline *lp)
freez
(
h
->
value
);
freez
(
h
);
}
VTAILQ_FOREACH_SAFE
(
h
,
&
lp
->
vcl_log
,
list
,
h2
)
{
VTAILQ_REMOVE
(
&
lp
->
vcl_log
,
h
,
list
);
freez
(
h
->
key
);
freez
(
h
->
value
);
freez
(
h
);
}
#undef freez
memset
(
lp
,
0
,
sizeof
*
lp
);
}
...
...
@@ -462,6 +482,25 @@ collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec,
}
break
;
case
SLT_VCL_Log
:
if
(
!
lp
->
active
)
break
;
split
=
strchr
(
ptr
,
':'
);
if
(
split
==
NULL
)
break
;
struct
hdr
*
h
;
h
=
malloc
(
sizeof
(
struct
hdr
));
AN
(
h
);
AN
(
split
);
h
->
key
=
trimline
(
ptr
,
split
);
h
->
value
=
trimline
(
split
+
1
,
end
);
VTAILQ_INSERT_HEAD
(
&
lp
->
vcl_log
,
h
,
list
);
break
;
case
SLT_VCL_call
:
if
(
!
lp
->
active
)
break
;
...
...
@@ -715,6 +754,14 @@ h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd,
VSB_cat
(
os
,
(
lp
->
df_handling
?
lp
->
df_handling
:
"-"
));
p
=
tmp
;
break
;
}
else
if
(
strncmp
(
fname
,
"VCL_Log:"
,
8
)
==
0
)
{
// support pulling entries logged with std.log() into output.
// Format: %{VCL_Log:keyname}x
// Logging: std.log("keyname:value")
h
=
vcl_log
(
lp
,
fname
+
8
);
VSB_cat
(
os
,
h
?
h
:
"-"
);
p
=
tmp
;
break
;
}
default:
fprintf
(
stderr
,
"Unknown format starting at: %s
\n
"
,
--
p
);
...
...
doc/sphinx/reference/varnishncsa.rst
View file @
d5117f53
...
...
@@ -116,6 +116,10 @@ The following options are available:
Varnish:handling
How the request was handled, whether it was a
cache hit, miss, pass, pipe or error.
VCL_Log:key
Output value set by std.log("key=value") in VCL.
-m tag:regex only list records where tag matches regex. Multiple
-m options are AND-ed together.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment