diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-22 05:19:07 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-22 05:19:07 -0800 |
commit | 13e9aefa1d7ec92600d46a004d5f38a4ff95ac7e (patch) | |
tree | b88dd27679b4a891bd6218498123811ab0d85596 /bgpd.go | |
parent | a5874d6912e2286fa5af5dc452e3d99ebc38c7a5 (diff) |
add --log-json command line option
During development, it's easy to parse a plain format by human.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'bgpd.go')
-rw-r--r-- | bgpd.go | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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" |