From 13e9aefa1d7ec92600d46a004d5f38a4ff95ac7e Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Mon, 22 Dec 2014 05:19:07 -0800 Subject: add --log-json command line option During development, it's easy to parse a plain format by human. Signed-off-by: FUJITA Tomonori --- bgpd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bgpd.go') diff --git a/bgpd.go b/bgpd.go index 38e5c849..8e9effd3 100644 --- a/bgpd.go +++ b/bgpd.go @@ -37,6 +37,7 @@ func main() { var opts struct { ConfigFile string `short:"f" long:"config-file" description:"specifying a config file"` LogLevel string `short:"l" long:"log-level" description:"specifying log level"` + LogJson bool `shot:"j" long:"log-json" description:"use json format for logging"` } _, err := flags.Parse(&opts) if err != nil { @@ -52,7 +53,9 @@ func main() { log.SetLevel(log.InfoLevel) } log.SetOutput(os.Stderr) - log.SetFormatter(&log.JSONFormatter{}) + if opts.LogJson { + log.SetFormatter(&log.JSONFormatter{}) + } if opts.ConfigFile == "" { opts.ConfigFile = "gobgpd.conf" -- cgit v1.2.3