Enable glog logging
Change enables glog logging and also make default flag values configurable. Signed-off-by: Ganesh Maharaj Mahalingam <ganesh.mahalingam@intel.com>
This commit is contained in:
1 parent
896ff184b5
commit
30dcd26da9
6 files changed
+13
-5
No files matched your search
@@ -43,7 +43,7 @@ func init() {
|
||||
operatorCmd.Flags().DurationVar(&mon.HealthCheckInterval, "mon-healthcheck-interval", mon.HealthCheckInterval, "mon health check interval (duration)")
|
||||
operatorCmd.Flags().DurationVar(&mon.MonOutTimeout, "mon-out-timeout", mon.MonOutTimeout, "mon out timeout (duration)")
|
||||
flags.SetFlagsFromEnv(operatorCmd.Flags(), rook.RookEnvVarPrefix)
|
||||
|
||||
flags.SetLoggingFlags(operatorCmd.Flags())
|
||||
operatorCmd.RunE = startOperator
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ https://github.com/rook/rook`,
|
||||
|
||||
func init() {
|
||||
flags.SetFlagsFromEnv(operatorCmd.Flags(), rook.RookEnvVarPrefix)
|
||||
flags.SetLoggingFlags(operatorCmd.Flags())
|
||||
|
||||
operatorCmd.RunE = startOperator
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ var (
|
||||
|
||||
func init() {
|
||||
flags.SetFlagsFromEnv(operatorCmd.Flags(), rook.RookEnvVarPrefix)
|
||||
flags.SetLoggingFlags(operatorCmd.Flags())
|
||||
operatorCmd.RunE = startOperator
|
||||
}
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ https://github.com/rook/rook`,
|
||||
|
||||
func init() {
|
||||
flags.SetFlagsFromEnv(operatorCmd.Flags(), rook.RookEnvVarPrefix)
|
||||
flags.SetLoggingFlags(operatorCmd.Flags())
|
||||
|
||||
operatorCmd.RunE = startOperator
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ limitations under the License.
|
||||
package rook
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -76,9 +75,6 @@ func SetLogLevel() {
|
||||
}
|
||||
|
||||
func LogStartupInfo(cmdFlags *pflag.FlagSet) {
|
||||
// workaround a k8s logging issue: https://github.com/kubernetes/kubernetes/issues/17162
|
||||
flag.CommandLine.Parse([]string{})
|
||||
|
||||
// log the version number, arguments, and all final flag values (environment variable overrides
|
||||
// have already been taken into account)
|
||||
flagValues := flags.GetFlagsAndValues(cmdFlags, "secret")
|
||||
|
||||
@@ -16,6 +16,7 @@ limitations under the License.
|
||||
package flags
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
@@ -81,6 +82,14 @@ func createRequiredFlagError(name string, flags []string) error {
|
||||
return fmt.Errorf("%s are required for %s", strings.Join(flags, ","), name)
|
||||
}
|
||||
|
||||
func SetLoggingFlags(flags *pflag.FlagSet) {
|
||||
//Add commandline flags to the flagset. We will always write to stderr
|
||||
//and not to a file by default
|
||||
flags.AddGoFlagSet(flag.CommandLine)
|
||||
flags.Set("logtostderr", "true")
|
||||
flags.Parse(nil)
|
||||
}
|
||||
|
||||
func SetFlagsFromEnv(flags *pflag.FlagSet, prefix string) error {
|
||||
flags.VisitAll(func(f *pflag.Flag) {
|
||||
envVar := prefix + "_" + strings.Replace(strings.ToUpper(f.Name), "-", "_", -1)
|
||||
|
||||
Reference in new issue
Block a user