Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Add zap logger support#93

Merged
black-adder merged 4 commits into
masterfrom
zap_logger
Feb 17, 2017
Merged

Add zap logger support#93
black-adder merged 4 commits into
masterfrom
zap_logger

Conversation

@black-adder
Copy link
Copy Markdown
Contributor

This is a breaking change, we should maybe consider keeping the original log as is and add the zap-log directory, or rererelease 2.0.0 again

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 17, 2017

Coverage Status

Coverage increased (+0.07%) to 81.931% when pulling 7f1a5ea on zap_logger into fe7c905 on master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.989% when pulling 4b98c2d on zap_logger into fe7c905 on master.

1 similar comment
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.989% when pulling 4b98c2d on zap_logger into fe7c905 on master.

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.989% when pulling 66a3d21 on zap_logger into fe7c905 on master.

1 similar comment
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.989% when pulling 66a3d21 on zap_logger into fe7c905 on master.

Comment thread tracer_test.go
NewConstSampler(true),
NewNullReporter(),
TracerOptions.Logger(StdLogger),
TracerOptions.Logger(log.StdLogger),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a test that shows backwards compatibility by passing jaeger.Logger as log.Logger?

@oibe
Copy link
Copy Markdown

oibe commented Feb 17, 2017

Other than Yuri's comment it LGTM

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.989% when pulling 2685e4b on zap_logger into fe7c905 on master.

1 similar comment
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.989% when pulling 2685e4b on zap_logger into fe7c905 on master.

@black-adder black-adder merged commit 372cf41 into master Feb 17, 2017
@black-adder black-adder deleted the zap_logger branch February 17, 2017 19:45
Copy link
Copy Markdown
Contributor

@akshayjshah akshayjshah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@black-adder Left some comments here - I think that this will be faster and easier to use if you change a few small things.

Comment thread log/zap/logger.go

// Infof logs a message at info priority
func (l *Logger) Infof(msg string, args ...interface{}) {
l.logger.Info(fmt.Sprintf(msg, args))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please first check if Info is enabled, since we don't always want to incur the overhead of string formatting:

if l.logger.Facility().Enabled(zap.InfoLevel) {
  l.logger.Info(fmt.Sprintf(msg, args))
}

In general, if you're going to do formatted logging, you're better off wrapping *zap.SugaredLogger, which already has an efficient version of this API. Accepting that type also makes it clear to users that you're planning to do printf-style logging. Every *zap.Logger can easily and cheaply be converted to a *zap.SugaredLogger.

Comment thread log/zap/logger.go
}

// NewLogger creates a new Logger.
func NewLogger(logger zap.Logger) *Logger {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exported function should take a *zap.Logger, since that's what all of zap's public APIs return.

Comment thread log/zap/logger_test.go
)

func TestLogger(t *testing.T) {
logger := NewLogger(*zap.New(zapcore.NewNopCore()))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zap.New(nil) instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Or, after uber-go/zap#326 lands, NewNop.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants