From 00cb1359132f4b5d60d2b971262d1ab985e9e0a9 Mon Sep 17 00:00:00 2001 From: boyska Date: Sun, 24 Mar 2019 20:17:09 +0100 Subject: [PATCH] add -fmt=json to circolog-tail --- cmd/circolog-tail/main.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/circolog-tail/main.go b/cmd/circolog-tail/main.go index 4d13950..1ca05af 100644 --- a/cmd/circolog-tail/main.go +++ b/cmd/circolog-tail/main.go @@ -57,6 +57,9 @@ func main() { addr := flag.String("addr", "localhost:9080", "http service address") querySocket := flag.String("socket", "", "Path to a unix domain socket for the HTTP server") backlogLimit := flag.Int("n", -1, "Limit the backlog length, defaults to no limit (-1)") + var format formatter.Format + format = formatter.FormatSyslog + flag.Var(&format, "fmt", "Output format [syslog|json]") var filter filtering.ExprValue flag.Var(&filter, "where", "sql-like query to filter logs") // TODO: change to color-mode=auto/no/always @@ -120,10 +123,12 @@ func main() { if !filter.Validate(parsed) { continue } - if err := formatter.WriteFormatted(os.Stdout, formatter.FormatSyslog, parsed); err != nil { + if err := formatter.WriteFormatted(os.Stdout, format, parsed); err != nil { log.Println("error printing", err) } - fmt.Println() + if format == formatter.FormatSyslog { // oops + fmt.Println() + } } }()