[master] 6058ced Revert to binary output by default when using -w
Federico G. Schwindt
fgsch at lodoss.net
Tue Dec 2 22:46:53 CET 2014
commit 6058cedf6ff5ff10f342a7e2728d709adc205a4e
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Tue Dec 2 21:15:16 2014 +0000
Revert to binary output by default when using -w
Add -A to enable text output. Discussed with Martin.
diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c
index fbb2f4d..d73e45d 100644
--- a/bin/varnishlog/varnishlog.c
+++ b/bin/varnishlog/varnishlog.c
@@ -54,7 +54,7 @@ static const char progname[] = "varnishlog";
struct log {
/* Options */
int a_opt;
- int B_opt;
+ int A_opt;
char *w_arg;
/* State */
@@ -77,13 +77,13 @@ openout(int append)
{
AN(LOG.w_arg);
- if (LOG.B_opt)
- LOG.fo = VSL_WriteOpen(VUT.vsl, LOG.w_arg, append, 0);
- else
+ 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);
if (LOG.fo == NULL)
VUT_Error(2, "Can't open output file (%s)",
- LOG.B_opt ? VSL_Error(VUT.vsl) : strerror(errno));
+ LOG.A_opt ? strerror(errno) : VSL_Error(VUT.vsl));
VUT.dispatch_priv = LOG.fo;
}
@@ -123,9 +123,9 @@ main(int argc, char * const *argv)
/* Append to file */
LOG.a_opt = 1;
break;
- case 'B':
- /* Binary output */
- LOG.B_opt = 1;
+ case 'A':
+ /* Text output */
+ LOG.A_opt = 1;
break;
case 'h':
/* Usage help */
@@ -145,10 +145,10 @@ main(int argc, char * const *argv)
usage(1);
/* Setup output */
- if (LOG.B_opt)
- VUT.dispatch_f = VSL_WriteTransactions;
- else
+ if (LOG.A_opt || !LOG.w_arg)
VUT.dispatch_f = VSL_PrintTransactions;
+ else
+ VUT.dispatch_f = VSL_WriteTransactions;
if (LOG.w_arg) {
openout(LOG.a_opt);
AN(LOG.fo);
diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h
index 55b30c7..1f2ab93 100644
--- a/bin/varnishlog/varnishlog_options.h
+++ b/bin/varnishlog/varnishlog_options.h
@@ -36,9 +36,9 @@
" overwrite it." \
)
-#define LOG_OPT_B \
- VOPT("B", "[-B]", "Binary output", \
- "Output binary data suitable for reading with -r." \
+#define LOG_OPT_A \
+ VOPT("A", "[-A]", "Text output", \
+ "Output data in ascii format." \
)
#define LOG_OPT_w \
@@ -50,8 +50,8 @@
)
LOG_OPT_a
+LOG_OPT_A
VSL_OPT_b
-LOG_OPT_B
VSL_OPT_c
VSL_OPT_C
VUT_OPT_d
More information about the varnish-commit
mailing list