forked from boyska/circolog
Merge branch 'tail-fmt' of boyska/circolog into master
This commit is contained in:
commit
aef8a277e5
1 changed files with 8 additions and 3 deletions
|
@ -57,11 +57,14 @@ func main() {
|
||||||
addr := flag.String("addr", "localhost:9080", "http service address")
|
addr := flag.String("addr", "localhost:9080", "http service address")
|
||||||
querySocket := flag.String("socket", "", "Path to a unix domain socket for the HTTP server")
|
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)")
|
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
|
var filter filtering.ExprValue
|
||||||
flag.Var(&filter, "where", "sql-like query to filter logs")
|
flag.Var(&filter, "where", "sql-like query to filter logs")
|
||||||
// TODO: change to color-mode=auto/no/always
|
// TODO: change to color-mode=auto/no/always
|
||||||
hasColor := BoolAuto_AUTO
|
hasColor := BoolAuto_AUTO
|
||||||
flag.Var(&hasColor, "color", "dis/enable colors")
|
flag.Var(&hasColor, "color", "dis/enable colors; yes/no/auto")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if hasColor == BoolAuto_NO || (!isatty.IsTerminal(os.Stdout.Fd()) && hasColor != BoolAuto_YES) {
|
if hasColor == BoolAuto_NO || (!isatty.IsTerminal(os.Stdout.Fd()) && hasColor != BoolAuto_YES) {
|
||||||
|
@ -120,10 +123,12 @@ func main() {
|
||||||
if !filter.Validate(parsed) {
|
if !filter.Validate(parsed) {
|
||||||
continue
|
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)
|
log.Println("error printing", err)
|
||||||
}
|
}
|
||||||
fmt.Println()
|
if format == formatter.FormatSyslog { // oops
|
||||||
|
fmt.Println()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue