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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2 #5

Merged
merged 30 commits into from
May 26, 2018
Merged

Version 2 #5

merged 30 commits into from
May 26, 2018

Conversation

JeanMertz
Copy link
Contributor

@JeanMertz JeanMertz commented May 21, 2018

  • no more global logger (now using logger.New which returns a new Zap logger)
  • better Stackdriver integration (thanks to https://github.com/tommy351/zap-stackdriver, I'll upstream the changes I made when I get the time)
  • Glide -> Dep
  • proper tests
  • drop tier log field
  • drop environment log field
  • add easy to use test logger at logger.TestNew
  • add CI integration

note: you can still easily set the tier and environment fields yourself on initialisation:

logger := logger.Must(logger.New(
  "my-service",
  "my-version",
  zap.Fields(
    zap.String("tier", "my-tier"),
    zap.String("environment", "my env"),
  ),
))

For more details on the Stackdriver log format, see:

@JeanMertz JeanMertz requested a review from jurre May 21, 2018 22:16
This way, the client can choose to either deal with the error themselves
in whatever appropriate way they want, or ust `logger.Must` if they
simply want to panic if an error occurs on initialization.
logger.go Outdated

// TestNew calls New, but returns both the logger, and an observer that can be
// used to fetch and compare delivered logs.
func TestNew(tb testing.TB, options ...zap.Option) (*zap.Logger, *observer.ObservedLogs) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect NewTest, if all the "constructor" functions begin with New it helps with autocompletion etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer TestNew, as this is supposed to a "public testing API" as described by Mitchell Hashimoto.

See:

Right now, it's only a single function, but there could be more down the line, and then it makes sense to always prefix them with Test (and move them into testing.go, but I didn't see the point of that for this one function, but maybe I should).

Also, in terms of autocompletion, all editors I use actually use fuzzy matching, so not sure if that's a reason to change this default.

@JeanMertz JeanMertz merged commit e217711 into master May 26, 2018
@JeanMertz JeanMertz deleted the version-2 branch May 26, 2018 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants