Skip to content
This repository is currently being migrated. It's locked while the migration is in progress.

RFC3339Nano timestamps and flags to configure level & format #23

Merged
merged 1 commit into from Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion main.go
Expand Up @@ -57,6 +57,7 @@ func init() {
}

func main() {
var loggerOpts zap.Options
var metricsAddr string
var enableLeaderElection bool
var apiSecretPath string
Expand Down Expand Up @@ -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
Expand Down