https://github.com/powerman/slogx
Golang extensions for log/slog
https://github.com/powerman/slogx
go golang golang-library logger-middleware logging logging-library
Last synced: 13 days ago
JSON representation
Golang extensions for log/slog
- Host: GitHub
- URL: https://github.com/powerman/slogx
- Owner: powerman
- License: mit
- Created: 2023-06-21T17:35:14.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2026-04-13T00:06:24.000Z (3 months ago)
- Last Synced: 2026-04-20T03:51:15.119Z (2 months ago)
- Topics: go, golang, golang-library, logger-middleware, logging, logging-library
- Language: Go
- Homepage:
- Size: 207 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Golang extensions for log/slog
[](LICENSE)
[](https://go.dev/)
[](https://github.com/powerman/slogx/actions/workflows/test.yml)
[](https://github.com/powerman/slogx/actions/workflows/test.yml)
[](https://goreportcard.com/report/github.com/powerman/slogx)
[](https://github.com/powerman/slogx/releases/latest)
[](https://pkg.go.dev/github.com/powerman/slogx)



## Features
### LayoutHandler
`LayoutHandler` is an alternative to `slog.TextHandler`
designed to make output easier to read with:
- Compact output for given attrs by replacing " key=" prefix before value.
- Reorder given attrs by moving them before message (prefix) or after other attrs (suffix).
- Vertical align for prefix attrs by enforcing min/max value width.
- Color output for given attrs.
## Recommendations
### Use NewContextHandler with linter
Disable non-Context slog functions (e.g. `slog.Info`) and methods using linter.
Example golangci-lint v2 config:
```yaml
linters:
settings:
sloglint:
context: all
```