@@ -30,8 +30,7 @@ import (
30
30
"go.uber.org/zap/zapcore"
31
31
)
32
32
33
- // EncoderConfigOption is being used to pass options
34
- // for configuring console/json encoder.
33
+ // EncoderConfigOption is a function that can modify a `zapcore.EncoderConfig`.
35
34
type EncoderConfigOption func (* zapcore.EncoderConfig )
36
35
37
36
// NewEncoderFunc is a function that creates an Encoder using the provided EncoderConfigOptions.
@@ -105,18 +104,18 @@ func Encoder(encoder zapcore.Encoder) func(o *Options) {
105
104
}
106
105
}
107
106
108
- func newJSONEncoder (ecfs ... EncoderConfigOption ) zapcore.Encoder {
107
+ func newJSONEncoder (opts ... EncoderConfigOption ) zapcore.Encoder {
109
108
encoderConfig := zap .NewProductionEncoderConfig ()
110
- for _ , f := range ecfs {
111
- f (& encoderConfig )
109
+ for _ , opt := range opts {
110
+ opt (& encoderConfig )
112
111
}
113
112
return zapcore .NewJSONEncoder (encoderConfig )
114
113
}
115
114
116
- func newConsoleEncoder (ecfs ... EncoderConfigOption ) zapcore.Encoder {
115
+ func newConsoleEncoder (opts ... EncoderConfigOption ) zapcore.Encoder {
117
116
encoderConfig := zap .NewDevelopmentEncoderConfig ()
118
- for _ , f := range ecfs {
119
- f (& encoderConfig )
117
+ for _ , opt := range opts {
118
+ opt (& encoderConfig )
120
119
}
121
120
return zapcore .NewConsoleEncoder (encoderConfig )
122
121
}
@@ -247,7 +246,7 @@ func NewRaw(opts ...Opts) *zap.Logger {
247
246
// BindFlags will parse the given flagset for zap option flags and set the log options accordingly
248
247
// zap-devel: Development Mode defaults(encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn)
249
248
// Production Mode defaults(encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error)
250
- // zap-encoder: Zap log encoding (Eg., 'json' or 'console')
249
+ // zap-encoder: Zap log encoding (one of 'json' or 'console')
251
250
// zap-log-level: Zap Level to configure the verbosity of logging. Can be one of 'debug', 'info', 'error',
252
251
// or any integer value > 0 which corresponds to custom debug levels of increasing verbosity")
253
252
// zap-stacktrace-level: Zap Level at and above which stacktraces are captured (one of 'info' or 'error')
@@ -263,7 +262,7 @@ func (o *Options) BindFlags(fs *flag.FlagSet) {
263
262
encVal .setFunc = func (fromFlag NewEncoderFunc ) {
264
263
o .NewEncoder = fromFlag
265
264
}
266
- fs .Var (& encVal , "zap-encoder" , "Zap log encoding (Eg., 'json' or 'console')" )
265
+ fs .Var (& encVal , "zap-encoder" , "Zap log encoding (one of 'json' or 'console')" )
267
266
268
267
// Set the Log Level
269
268
var levelVal levelFlag
0 commit comments