add -fmt=json to circolog-tail

This commit is contained in:
boyska 2019-03-24 20:17:09 +01:00
parent 7dc3b5a7bb
commit 00cb135913

View file

@ -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,11 +123,13 @@ 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)
}
if format == formatter.FormatSyslog { // oops
fmt.Println()
}
}
}()
for {