Commit fd76408f authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

varnishlog: New -u option for unbuffered output

The option was present in libvarnishapi but never exposed.
parent 12fca058
......@@ -60,6 +60,7 @@ static struct log {
/* Options */
int a_opt;
int A_opt;
int u_opt;
char *w_arg;
/* State */
......@@ -74,7 +75,7 @@ openout(int append)
if (LOG.A_opt)
LOG.fo = fopen(LOG.w_arg, append ? "a" : "w");
else
LOG.fo = VSL_WriteOpen(vut->vsl, LOG.w_arg, append, 0);
LOG.fo = VSL_WriteOpen(vut->vsl, LOG.w_arg, append, LOG.u_opt);
if (LOG.fo == NULL)
VUT_Error(vut, 2, "Cannot open output file (%s)",
LOG.A_opt ? strerror(errno) : VSL_Error(vut->vsl));
......@@ -127,6 +128,10 @@ main(int argc, char * const *argv)
case 'h':
/* Usage help */
VUT_Usage(vut, &vopt_spec, 0);
case 'u':
/* Unbuffered output */
LOG.u_opt = 1;
break;
case 'w':
/* Write to file */
REPLACE(LOG.w_arg, optarg);
......
......@@ -44,6 +44,12 @@
" data in ascii format." \
)
#define LOG_OPT_u \
VOPT("u", "[-u]", "Unbuffered output", \
"When writing output to a file with the -w option, output" \
" data is not buffered." \
)
#define LOG_OPT_w \
VOPT("w:", "[-w <filename>]", "Output filename", \
"Redirect output to file. The file will be overwritten" \
......@@ -77,6 +83,7 @@ VUT_OPT_r
VSL_OPT_R
VUT_OPT_t
VSL_OPT_T
LOG_OPT_u
VSL_OPT_v
VUT_GLOBAL_OPT_V
LOG_OPT_w
......
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