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