Skip to content

Commit 8144092

Browse files
authored
Merge pull request #1340 from nader-ziada/fix-typo
🌱 fix DestWritter var name typo
2 parents 0133f4f + 1d53a12 commit 8144092

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

pkg/log/zap/zap.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
6060
func 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
162167
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
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))

pkg/log/zap/zap_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ var _ = Describe("Zap options setup", func() {
137137
It("should set a custom writer", func() {
138138
var w fakeSyncWriter
139139
WriteTo(&w)(opts)
140-
Expect(opts.DestWritter).To(Equal(&w))
140+
Expect(opts.DestWriter).To(Equal(&w))
141141
})
142142
})
143143

0 commit comments

Comments
 (0)