Skip to content

Commit

Permalink
Merge pull request #1340 from nader-ziada/fix-typo
Browse files Browse the repository at this point in the history
馃尡 fix DestWritter var name typo
  • Loading branch information
k8s-ci-robot committed Jan 21, 2021
2 parents 0133f4f + 1d53a12 commit 8144092
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions pkg/log/zap/zap.go
Expand Up @@ -56,10 +56,10 @@ func UseDevMode(enabled bool) Opts {
}

// WriteTo configures the logger to write to the given io.Writer, instead of standard error.
// See Options.DestWritter
// See Options.DestWriter
func WriteTo(out io.Writer) Opts {
return func(o *Options) {
o.DestWritter = out
o.DestWriter = out
}
}

Expand Down Expand Up @@ -143,8 +143,13 @@ type Options struct {
// NewEncoder configures Encoder using the provided EncoderConfigOptions.
// Note that the NewEncoder function is not used when the Encoder option is already set.
NewEncoder NewEncoderFunc
// DestWriter controls the destination of the log output. Defaults to
// os.Stderr.
DestWriter io.Writer
// DestWritter controls the destination of the log output. Defaults to
// os.Stderr.
//
// Deprecated: Use DestWriter instead
DestWritter io.Writer
// Level configures the verbosity of the logging. Defaults to Debug when
// Development is true and Info otherwise
Expand All @@ -160,8 +165,11 @@ type Options struct {

// addDefaults adds defaults to the Options
func (o *Options) addDefaults() {
if o.DestWritter == nil {
o.DestWritter = os.Stderr
if o.DestWriter == nil && o.DestWritter == nil {
o.DestWriter = os.Stderr
} else if o.DestWriter == nil && o.DestWritter != nil {
// while misspelled DestWritter is deprecated but still not removed
o.DestWriter = o.DestWritter
}

if o.Development {
Expand Down Expand Up @@ -216,7 +224,7 @@ func NewRaw(opts ...Opts) *zap.Logger {
o.addDefaults()

// this basically mimics New<type>Config, but with a custom sink
sink := zapcore.AddSync(o.DestWritter)
sink := zapcore.AddSync(o.DestWriter)

o.ZapOpts = append(o.ZapOpts, zap.AddCallerSkip(1), zap.ErrorOutput(sink))
log := zap.New(zapcore.NewCore(&KubeAwareEncoder{Encoder: o.Encoder, Verbose: o.Development}, sink, o.Level))
Expand Down
2 changes: 1 addition & 1 deletion pkg/log/zap/zap_test.go
Expand Up @@ -137,7 +137,7 @@ var _ = Describe("Zap options setup", func() {
It("should set a custom writer", func() {
var w fakeSyncWriter
WriteTo(&w)(opts)
Expect(opts.DestWritter).To(Equal(&w))
Expect(opts.DestWriter).To(Equal(&w))
})
})

Expand Down

0 comments on commit 8144092

Please sign in to comment.