-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add Zerolog formatter #50
Conversation
@samber , Should I raise an issue before submitting a PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add it to readme as well. ✌️
(ctrl-f logrus)
Makefile
Outdated
watch-test: | ||
reflex -t 50ms -s -- sh -c 'gotest -race -v ./...' | ||
reflex -t 50ms -s -- sh -c 'gotest -race -v ./... && go -C loggers/zerolog test -race -v ./...' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm pretty sure it is not necessary, since you declared this submodule in go.work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, there is no a straight way to do that right now.
There is a proposal for that: golang/go#71294 (accepted, but it's not a part of cmd/go
so far)
go test -race -v ./...
=== RUN TestErrorsIs
--- PASS: TestErrorsIs (0.00s)
=== RUN TestErrorsAs
--- PASS: TestErrorsAs (0.00s)
=== RUN TestDereferencePointers
--- PASS: TestDereferencePointers (0.00s)
=== RUN TestOopsWrap
--- PASS: TestOopsWrap (0.00s)
=== RUN TestOopsWrap_wrapped
--- PASS: TestOopsWrap_wrapped (0.10s)
=== RUN TestOopsWrapf
--- PASS: TestOopsWrapf (0.00s)
=== RUN TestOopsFromContext
--- PASS: TestOopsFromContext (0.00s)
=== RUN TestOopsNew
--- PASS: TestOopsNew (0.00s)
=== RUN TestOopsErrorf
--- PASS: TestOopsErrorf (0.00s)
=== RUN TestOopsCode
--- PASS: TestOopsCode (0.00s)
=== RUN TestOopsTime
--- PASS: TestOopsTime (0.00s)
=== RUN TestOopsSince
--- PASS: TestOopsSince (0.01s)
=== RUN TestOopsDuration
--- PASS: TestOopsDuration (0.01s)
=== RUN TestOopsIn
--- PASS: TestOopsIn (0.00s)
=== RUN TestOopsTags
--- PASS: TestOopsTags (0.00s)
=== RUN TestOopsTx
--- PASS: TestOopsTx (0.00s)
=== RUN TestOopsTxSpanFromOtel
--- PASS: TestOopsTxSpanFromOtel (0.00s)
=== RUN TestOopsWith
--- PASS: TestOopsWith (0.00s)
=== RUN TestOopsWithContext
--- PASS: TestOopsWithContext (0.00s)
=== RUN TestOopsWithLazyEvaluation
--- PASS: TestOopsWithLazyEvaluation (0.00s)
=== RUN TestOopsHint
--- PASS: TestOopsHint (0.00s)
=== RUN TestOopsPublic
--- PASS: TestOopsPublic (0.00s)
=== RUN TestOopsOwner
--- PASS: TestOopsOwner (0.00s)
=== RUN TestOopsUser
--- PASS: TestOopsUser (0.00s)
=== RUN TestOopsTenant
--- PASS: TestOopsTenant (0.00s)
=== RUN TestOopsRequest
--- PASS: TestOopsRequest (0.00s)
=== RUN TestOopsMixed
--- PASS: TestOopsMixed (0.00s)
=== RUN TestOopsMixedWithGetters
--- PASS: TestOopsMixedWithGetters (0.00s)
=== RUN TestOopsLogValuer
--- PASS: TestOopsLogValuer (0.00s)
=== RUN TestOopsFormatSummary
--- PASS: TestOopsFormatSummary (0.00s)
=== RUN TestOopsFormatVerbose
--- PASS: TestOopsFormatVerbose (0.00s)
=== RUN TestOopsMarshalJSON
--- PASS: TestOopsMarshalJSON (0.00s)
=== RUN TestOopsGetPublic
--- PASS: TestOopsGetPublic (0.00s)
=== RUN TestRemoveGoPath
--- PASS: TestRemoveGoPath (0.00s)
=== RUN TestStacktrace
--- PASS: TestStacktrace (0.00s)
PASS
ok github.com/samber/oops (cached)
(it does not run the new test)
go -C loggers/zerolog test -race -v ./...
=== RUN TestZerologFormatter
--- PASS: TestZerologFormatter (0.00s)
PASS
ok github.com/samber/oops/loggers/zerolog (cached)
Possible one-liner (I'm not sure if that's gonna work in CI):
go list -f '{{.Dir}}' -m | xargs go test -race -v
? github.com/samber/oops/examples/log [no test files]
? github.com/samber/oops/examples/panic [no test files]
? github.com/samber/oops/examples/logrus [no test files]
? github.com/samber/oops/examples/segfault [no test files]
? github.com/samber/oops/examples/slog [no test files]
? github.com/samber/oops/examples/sources [no test files]
? github.com/samber/oops/examples/zerolog [no test files]
=== RUN TestErrorsIs
--- PASS: TestErrorsIs (0.00s)
=== RUN TestErrorsAs
--- PASS: TestErrorsAs (0.00s)
=== RUN TestDereferencePointers
--- PASS: TestDereferencePointers (0.00s)
=== RUN TestOopsWrap
--- PASS: TestOopsWrap (0.00s)
=== RUN TestOopsWrap_wrapped
--- PASS: TestOopsWrap_wrapped (0.10s)
=== RUN TestOopsWrapf
--- PASS: TestOopsWrapf (0.00s)
=== RUN TestOopsFromContext
--- PASS: TestOopsFromContext (0.00s)
=== RUN TestOopsNew
--- PASS: TestOopsNew (0.00s)
=== RUN TestOopsErrorf
--- PASS: TestOopsErrorf (0.00s)
=== RUN TestOopsCode
--- PASS: TestOopsCode (0.00s)
=== RUN TestOopsTime
--- PASS: TestOopsTime (0.00s)
=== RUN TestOopsSince
--- PASS: TestOopsSince (0.01s)
=== RUN TestOopsDuration
--- PASS: TestOopsDuration (0.01s)
=== RUN TestOopsIn
--- PASS: TestOopsIn (0.00s)
=== RUN TestOopsTags
--- PASS: TestOopsTags (0.00s)
=== RUN TestOopsTx
--- PASS: TestOopsTx (0.00s)
=== RUN TestOopsTxSpanFromOtel
--- PASS: TestOopsTxSpanFromOtel (0.00s)
=== RUN TestOopsWith
--- PASS: TestOopsWith (0.00s)
=== RUN TestOopsWithContext
--- PASS: TestOopsWithContext (0.00s)
=== RUN TestOopsWithLazyEvaluation
--- PASS: TestOopsWithLazyEvaluation (0.00s)
=== RUN TestOopsHint
--- PASS: TestOopsHint (0.00s)
=== RUN TestOopsPublic
--- PASS: TestOopsPublic (0.00s)
=== RUN TestOopsOwner
--- PASS: TestOopsOwner (0.00s)
=== RUN TestOopsUser
--- PASS: TestOopsUser (0.00s)
=== RUN TestOopsTenant
--- PASS: TestOopsTenant (0.00s)
=== RUN TestOopsRequest
--- PASS: TestOopsRequest (0.00s)
=== RUN TestOopsMixed
--- PASS: TestOopsMixed (0.00s)
=== RUN TestOopsMixedWithGetters
--- PASS: TestOopsMixedWithGetters (0.00s)
=== RUN TestOopsLogValuer
--- PASS: TestOopsLogValuer (0.00s)
=== RUN TestOopsFormatSummary
--- PASS: TestOopsFormatSummary (0.00s)
=== RUN TestOopsFormatVerbose
--- PASS: TestOopsFormatVerbose (0.00s)
=== RUN TestOopsMarshalJSON
--- PASS: TestOopsMarshalJSON (0.00s)
=== RUN TestOopsGetPublic
--- PASS: TestOopsGetPublic (0.00s)
=== RUN TestRemoveGoPath
--- PASS: TestRemoveGoPath (0.00s)
=== RUN TestStacktrace
--- PASS: TestStacktrace (0.00s)
PASS
ok github.com/samber/oops (cached)
testing: warning: no tests to run
PASS
ok github.com/samber/oops/loggers/logrus (cached) [no tests to run]
=== RUN TestZerologFormatter
--- PASS: TestZerologFormatter (0.00s)
PASS
ok github.com/samber/oops/loggers/zerolog (cached)
? github.com/samber/oops/recovery/gin [no test files]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes, sorry. I did this in another project:
MODULES=$(shell go list -m)
test:
go test -race -v ${MODULES} ./...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feel free to change the readme and add logrus submodule
the limit of both methods is that go.work version must be compatible with submodule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I precisely understand what you mean.
What readme do you mean in this case?
I propose to use your approach from that another project:
MODULES=$(shell go list -m)
build:
go build -v ./...
test:
go test -race -v ${MODULES} ./...
watch-test:
reflex -t 50ms -s -- sh -c 'gotest -race -v ${MODULES} ./...'
and update other goals same way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I mean the Makefile :-(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the latest commit with the changes in Makefile
.
Same issue is applicable to golangci-lint
, the difference is that it wants directories, not packages (updated it as well and it forced me to fix a couple of files)
I've updated the root |
Thanks! Let's merge ;) [edit] i'm going to make a release as soon as the other pr is done |
Add Zerolog formatter
Log entry looks like this: