@@ -56,10 +56,10 @@ func UseDevMode(enabled bool) Opts {
56
56
}
57
57
58
58
// WriteTo configures the logger to write to the given io.Writer, instead of standard error.
59
- // See Options.DestWritter
59
+ // See Options.DestWriter
60
60
func WriteTo (out io.Writer ) Opts {
61
61
return func (o * Options ) {
62
- o .DestWritter = out
62
+ o .DestWriter = out
63
63
}
64
64
}
65
65
@@ -143,8 +143,13 @@ type Options struct {
143
143
// NewEncoder configures Encoder using the provided EncoderConfigOptions.
144
144
// Note that the NewEncoder function is not used when the Encoder option is already set.
145
145
NewEncoder NewEncoderFunc
146
+ // DestWriter controls the destination of the log output. Defaults to
147
+ // os.Stderr.
148
+ DestWriter io.Writer
146
149
// DestWritter controls the destination of the log output. Defaults to
147
150
// os.Stderr.
151
+ //
152
+ // Deprecated: Use DestWriter instead
148
153
DestWritter io.Writer
149
154
// Level configures the verbosity of the logging. Defaults to Debug when
150
155
// Development is true and Info otherwise
@@ -160,8 +165,11 @@ type Options struct {
160
165
161
166
// addDefaults adds defaults to the Options
162
167
func (o * Options ) addDefaults () {
163
- if o .DestWritter == nil {
164
- o .DestWritter = os .Stderr
168
+ if o .DestWriter == nil && o .DestWritter == nil {
169
+ o .DestWriter = os .Stderr
170
+ } else if o .DestWriter == nil && o .DestWritter != nil {
171
+ // while misspelled DestWritter is deprecated but still not removed
172
+ o .DestWriter = o .DestWritter
165
173
}
166
174
167
175
if o .Development {
@@ -216,7 +224,7 @@ func NewRaw(opts ...Opts) *zap.Logger {
216
224
o .addDefaults ()
217
225
218
226
// this basically mimics New<type>Config, but with a custom sink
219
- sink := zapcore .AddSync (o .DestWritter )
227
+ sink := zapcore .AddSync (o .DestWriter )
220
228
221
229
o .ZapOpts = append (o .ZapOpts , zap .AddCallerSkip (1 ), zap .ErrorOutput (sink ))
222
230
log := zap .New (zapcore .NewCore (& KubeAwareEncoder {Encoder : o .Encoder , Verbose : o .Development }, sink , o .Level ))
0 commit comments