diff --git a/README.md b/README.md index cf493fb8..62302e8d 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,15 @@ The following flags are supported: -node-delete-gc-interval duration Frequency of node garbage collection. (default 1h0m0s) -node-delete-workers int - Maximum concurrent node delete operations. (default 5) + Maximum concurrent node delete operations. (default 5) + -zap-devel + Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error) + -zap-encoder value + Zap log encoding (one of 'json' or 'console') + -zap-log-level value + Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error', or any integer value > 0 which corresponds to custom debug levels of increasing verbosity + -zap-stacktrace-level value + Zap Level at and above which stacktraces are captured (one of 'info', 'error'). ``` ## Setup/Development diff --git a/main.go b/main.go index b8553c17..70d3cf9f 100644 --- a/main.go +++ b/main.go @@ -57,6 +57,7 @@ func init() { } func main() { + var loggerOpts zap.Options var metricsAddr string var enableLeaderElection bool var apiSecretPath string @@ -88,9 +89,17 @@ func main() { flag.IntVar(&nodeDeleteWorkers, "node-delete-workers", 5, "Maximum concurrent node delete operations.") flag.IntVar(&nsDeleteWorkers, "namespace-delete-workers", 5, "Maximum concurrent namespace delete operations.") + loggerOpts.BindFlags(flag.CommandLine) flag.Parse() - ctrl.SetLogger(zap.New(zap.StacktraceLevel(zapcore.FatalLevel))) + f := func(ec *zapcore.EncoderConfig) { + ec.TimeKey = "timestamp" + ec.EncodeTime = zapcore.RFC3339NanoTimeEncoder + } + encoderOpts := func(o *zap.Options) { + o.EncoderConfigOptions = append(o.EncoderConfigOptions, f) + } + ctrl.SetLogger(zap.New(zap.UseFlagOptions(&loggerOpts), zap.StacktraceLevel(zapcore.PanicLevel), encoderOpts)) // Block startup until there is a working StorageOS API connection. Unless // we loop here, we'll get a number of failures on cold cluster start as it