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

Add zap logger support #93

Merged
merged 4 commits into from
Feb 17, 2017
Merged

Add zap logger support #93

merged 4 commits into from
Feb 17, 2017

Conversation

black-adder
Copy link
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

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

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

Coverage Status

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

@coveralls
Copy link

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

Coverage Status

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

@@ -203,15 +204,15 @@ func TestTracerOptions(t *testing.T) {
openTracer, closer := NewTracer("DOOP", // respect the classics, man!
NewConstSampler(true),
NewNullReporter(),
TracerOptions.Logger(StdLogger),
TracerOptions.Logger(log.StdLogger),
Copy link
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

oibe commented Feb 17, 2017

Other than Yuri's comment it LGTM

@coveralls
Copy link

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

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
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.


// Infof logs a message at info priority
func (l *Logger) Infof(msg string, args ...interface{}) {
l.logger.Info(fmt.Sprintf(msg, args))
Copy link
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.

}

// NewLogger creates a new Logger.
func NewLogger(logger zap.Logger) *Logger {
Copy link
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.

)

func TestLogger(t *testing.T) {
logger := NewLogger(*zap.New(zapcore.NewNopCore()))
Copy link
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
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