vlib: unix cli - log cli commands one per line
This changeset modifies the log output so that cli commands now look like:
cat /tmp/vpp-cli.log
2020/03/10 19:24:42:186: ***** Start: PID 29570 *****
/* [0] is stdin */
2020/03/10 19:24:53:518[0]: show clock
2020/03/10 19:24:56:078[0]: show clock
2020/03/10 19:25:01:983[0]: show pci
/* [1] is vppctl socket */
2020/03/10 19:26:14:372[1]: show ver
2020/03/10 19:26:23:395[1]: show hardware-interfaces
2020/03/10 19:26:28:507[1]: q
instead of:
cat /tmp/vpp-cli.log
2020/03/01 00:40:12:834: ***** Start: PID 29974 *****
2020/03/01 00:40:24:969[0]: show interface2020/03/01 00:40:31:945[0]: show clo2020/03/01 00:40:41:288[0]: show classify 2020/03/01 00:40:43:753[0]: show classify ?2020/03/01 00:40:53:392[0]: show classify tables2020/03/01 00:40:57:352[0]: quit
Type: improvement
Change-Id: I38d85535977296d174db7121ae340850b6476a39
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index b0ed9d2..6e566d1 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -2557,6 +2557,8 @@
format_timeval, 0 /* current bat-time */ ,
0 /* current bat-format */ ,
cli_file_index, cf->current_command);
+ if (cf->current_command[vec_len (cf->current_command) - 1] != '\n')
+ lv = format (lv, "\n");
int rv __attribute__ ((unused)) = write (um->log_fd, lv, vec_len (lv));
}