From b94c5d4026ff48190a7a295f2dfd8775e6c306f7 Mon Sep 17 00:00:00 2001 From: Asim Date: Sun, 30 Aug 2015 02:24:16 +0100 Subject: [PATCH] Semi working solution for glog flags --- cmd/cmd.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/cmd/cmd.go b/cmd/cmd.go index a18d9e88..7efe6808 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -1,6 +1,8 @@ package cmd import ( + "flag" + "fmt" "io" "os" "strings" @@ -87,6 +89,36 @@ var ( EnvVar: "MICRO_TRANSPORT_ADDRESS", Usage: "Comma-separated list of transport addresses", }, + + // logging flags + cli.BoolFlag{ + Name: "logtostderr", + Usage: "log to standard error instead of files", + }, + cli.BoolFlag{ + Name: "alsologtostderr", + Usage: "log to standard error as well as files", + }, + cli.StringFlag{ + Name: "log_dir", + Usage: "log files will be written to this directory instead of the default temporary directory", + }, + cli.StringFlag{ + Name: "stderrthreshold", + Usage: "logs at or above this threshold go to stderr", + }, + cli.StringFlag{ + Name: "v", + Usage: "log level for V logs", + }, + cli.StringFlag{ + Name: "vmodule", + Usage: "comma-separated list of pattern=N settings for file-filtered logging", + }, + cli.StringFlag{ + Name: "log_backtrace_at", + Usage: "when logging hits line file:N, emit a stack trace", + }, } Brokers = map[string]func([]string, ...broker.Option) broker.Broker{ @@ -140,6 +172,14 @@ func Setup(c *cli.Context) error { ) client.DefaultClient = client.NewClient() + flag.Set("logtostderr", fmt.Sprintf("%v", c.Bool("logtostderr"))) + flag.Set("alsologtostderr", fmt.Sprintf("%v", c.Bool("alsologtostderr"))) + flag.Set("stderrthreshold", c.String("stderrthreshold")) + flag.Set("log_backtrace_at", c.String("log_backtrace_at")) + flag.Set("log_dir", c.String("log_dir")) + flag.Set("vmodule", c.String("vmodule")) + flag.Set("v", c.String("v")) + flag.Parse() return nil }