https://github.com/0x2b3bfa0/logrusctx
Port of github.com/juju/zaputil/zapctx for github.com/sirupsen/logrus
https://github.com/0x2b3bfa0/logrusctx
context golang logrus
Last synced: 10 months ago
JSON representation
Port of github.com/juju/zaputil/zapctx for github.com/sirupsen/logrus
- Host: GitHub
- URL: https://github.com/0x2b3bfa0/logrusctx
- Owner: 0x2b3bfa0
- License: gpl-3.0
- Created: 2022-11-11T17:15:03.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-11T20:27:36.000Z (about 3 years ago)
- Last Synced: 2024-10-05T13:21:05.902Z (over 1 year ago)
- Topics: context, golang, logrus
- Language: Go
- Homepage: https://pkg.go.dev/github.com/0x2b3bfa0/logrusctx
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `logrusctx` [![reference][reference-badge]][reference] [![tests][tests-badge]][tests]
Port of [github.com/juju/zaputil/zapctx](https://pkg.go.dev/github.com/juju/zaputil/zapctx) for [github.com/sirupsen/logrus](https://pkg.go.dev/github.com/sirupsen/logrus)
## Example
```go
package main
import (
"context"
"github.com/sirupsen/logrus"
"github.com/0x2b3bfa0/logrusctx"
)
func main() {
ctx := context.Background()
logger := logrus.WithField("key", "value")
ctx = logrusctx.WithLogger(ctx, logger)
worker(ctx)
}
func worker(ctx context.Context) {
logrusctx.Info(ctx, "test")
}
```
[reference-badge]: https://pkg.go.dev/badge/github.com/0x2b3bfa0/logrusctx.svg
[reference]: https://pkg.go.dev/github.com/0x2b3bfa0/logrusctx
[tests-badge]: https://github.com/0x2b3bfa0/logrusctx/actions/workflows/test.yml/badge.svg?branch=main
[tests]: https://github.com/0x2b3bfa0/logrusctx/actions/workflows/test.yml