https://github.com/ipfans/fxslog
Integration slog with uber-go/fx
https://github.com/ipfans/fxslog
Last synced: over 1 year ago
JSON representation
Integration slog with uber-go/fx
- Host: GitHub
- URL: https://github.com/ipfans/fxslog
- Owner: ipfans
- License: mit
- Created: 2022-11-28T00:47:01.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-21T16:21:18.000Z (almost 3 years ago)
- Last Synced: 2025-01-31T10:11:24.744Z (over 1 year ago)
- Language: Go
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fxslog
[](https://github.com/ipfans/fxslog/blob/main/LICENSE)
[](http://godoc.org/github.com/ipfans/fxslog)
[](https://github.com/ipfans/fxslog/releases)
[](https://github.com/ipfans/fxslog/actions/workflows/pull-request.yml)
[](https://github.com/ipfans/fxslog/blob/main/go.mod)
[](https://goreportcard.com/report/github.com/ipfans/fxslog)
[](https://github.com/ipfans/fxslog/issues)
Integration slog with `uber-go/fx`.
Note: **slog required Go 1.19+**
## HOWTO
```go
app := fx.New(
fx.Provide(func() *slog.Logger {
return slog.New(slog.NewJSONHandler(os.Stdout))
}),
fx.WithLogger(func(logger *slog.Logger) fxevent.Logger {
return fxslog.New(logger)
}),
)
defer app.Stop(context.TODO())
app.Start(context.TODO())
```