Simple logger with DataDog’s span support. Uses Zap under the hood.
Now you can add this package via;
go get github.com/deliveryhero/honeylogger
You can add these lines to your existing linter yaml if you use wrapcheck
linter:
linters-settings:
wrapcheck:
ignoreSigs:
- .Errorf(
- errors.New(
- errors.Unwrap(
- .Wrap(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
- .WithStack(
- .WrapError(
logger := logging.NewLogger("stderr")
logger.Fatal(errors.Wrap(err, "invalid server port"))
This adds span information if context has DataDog Span object.
logger := logging.NewLogger("stderr")
span, spanCtx := tracer.StartSpanFromContext(...)
defer func() {
span.Finish(tracer.WithError(err))
}()
logger.InfoContext(spanCtx, fmt.Sprintf("[outboxService.ticked] non published count: %v", count))
logger := logging.NewLogger("stderr")
span, spanCtx := tracer.StartSpanFromContext(...)
defer func() {
span.Finish(tracer.WithError(err))
}()
logger.InfoSpan( fmt.Sprintf("[outboxService.ticked] non published count: %v",count), span)
rake -T
rake bump[revision] # bump version, default is: patch
rake default # default task
rake doc[port] # run doc server
rake mockery # run mockery
rake publish[revision] # publish new version of the library, default is: patch
rake test # run tests
To run tests, use rake test
or;
go test -p 1 -v -race ./...
logger := &mocks.Logger{}
logger.On("Info", mock.Anything).Return()
logger.On("InfoSpan", mock.Anything, mock.Anything, mock.Anything).Return()
logger.On("InfoContext", mock.Anything, mock.Anything, mock.Anything).Return()
Make sure you have already installed godoc
unless:
go install golang.org/x/tools/cmd/godoc@latest
godoc -http=:9009
or, use rake tasks:
rake doc
uses default port which is9009
rake doc[8008]
uses given8008
as port number
then;
# for default port
open https://localhost:9009/pkg/github.com/deliveryhero/honeylogger/logging/
Prerequisites
- You need to be in
main
branch - You need to be ready to bump to a new version
Use rake publish[revision]
task to bump new version and push newly created
tag and updated code to remote and verify go package. (all in one!)
rake publish
:0.0.0
->0.0.1
, default revision ispatch
rake publish[minor]
:0.0.0
->0.1.0
rake publish[major]
:0.0.0
->1.0.0
- Hakan Kutluay - Creator, maintainer
- Erhan Akpınar - Contributor
- Uğur "vigo" Özyılmazel - Contributor
All PR’s are welcome!
fork
(https://github.com/deliveryhero/honeylogger/fork)- Create your
branch
(git checkout -b my-feature
) commit
yours (git commit -am 'add some functionality'
)push
yourbranch
(git push origin my-feature
)- Than create a new Pull Request!
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.