Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃尡 fix DestWritter var name typo #1340

Merged
merged 1 commit into from Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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