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

Commit

Permalink
RFC3339Nano and flags to configure level & format (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
croomes committed Jan 20, 2021
1 parent bd76e26 commit 26c352a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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 @@ -58,6 +58,7 @@ func init() {
}

func main() {
var loggerOpts zap.Options
var metricsAddr string
var enableLeaderElection bool
var apiSecretPath string
Expand Down Expand Up @@ -93,9 +94,17 @@ func main() {
flag.IntVar(&nsDeleteWorkers, "namespace-delete-workers", 5, "Maximum concurrent namespace delete operations.")
flag.IntVar(&nodeLabelSyncWorkers, "node-label-sync-workers", 5, "Maximum concurrent node label sync 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

0 comments on commit 26c352a

Please sign in to comment.