@@ -56,10 +56,10 @@ func UseDevMode(enabled bool) Opts {
5656}
5757
5858// WriteTo configures the logger to write to the given io.Writer, instead of standard error.
59- // See Options.DestWritter
59+ // See Options.DestWriter
6060func WriteTo (out io.Writer ) Opts {
6161 return func (o * Options ) {
62- o .DestWritter = out
62+ o .DestWriter = out
6363 }
6464}
6565
@@ -143,8 +143,13 @@ type Options struct {
143143 // NewEncoder configures Encoder using the provided EncoderConfigOptions.
144144 // Note that the NewEncoder function is not used when the Encoder option is already set.
145145 NewEncoder NewEncoderFunc
146+ // DestWriter controls the destination of the log output. Defaults to
147+ // os.Stderr.
148+ DestWriter io.Writer
146149 // DestWritter controls the destination of the log output. Defaults to
147150 // os.Stderr.
151+ //
152+ // Deprecated: Use DestWriter instead
148153 DestWritter io.Writer
149154 // Level configures the verbosity of the logging. Defaults to Debug when
150155 // Development is true and Info otherwise
@@ -160,8 +165,11 @@ type Options struct {
160165
161166// addDefaults adds defaults to the Options
162167func (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
165173 }
166174
167175 if o .Development {
@@ -216,7 +224,7 @@ func NewRaw(opts ...Opts) *zap.Logger {
216224 o .addDefaults ()
217225
218226 // this basically mimics New<type>Config, but with a custom sink
219- sink := zapcore .AddSync (o .DestWritter )
227+ sink := zapcore .AddSync (o .DestWriter )
220228
221229 o .ZapOpts = append (o .ZapOpts , zap .AddCallerSkip (1 ), zap .ErrorOutput (sink ))
222230 log := zap .New (zapcore .NewCore (& KubeAwareEncoder {Encoder : o .Encoder , Verbose : o .Development }, sink , o .Level ))
0 commit comments