sloglint is a Go linter focused on code that uses the standard library’s log/slog package.
Structured logging APIs are flexible, but that flexibility can lead to inconsistent messages, key conventions and calling styles across a codebase. sloglint lets teams encode those preferences as static checks so logging conventions can be enforced automatically during development and continuous integration. It is particularly useful in larger services where multiple contributors might otherwise produce structurally different log records for similar events.
This is free and open source software.
Key Features
- Can report use of global loggers or restrict the check to the default slog logger.
- Can require context-aware logging functions, including a mode that considers whether a context is available in the surrounding function.
- Suggests slog.DiscardHandler where an older discard-handler construction can be simplified.
- Can require log messages to be static strings or constants instead of dynamically formatted text.
- Supports lowercased or capitalized message-style policies.
- Detects calls that mix key-value pairs with slog attributes.
- Can enforce either key-value arguments or attribute arguments as the preferred style.
- Can require logging arguments to appear on separate lines.
- Can require raw string keys to be replaced by constants.
- Supports allowlists and denylists for structured logging keys.
- Can enforce snake_case, kebab-case, camelCase or PascalCase key naming.
- Provides autofixes for selected checks.
- Can analyse user-defined logging wrappers by configuring function names and argument positions.
- Integrates with Golangci-lint and can also be used as a standalone analyzer.
Website: github.com/go-simpler/sloglint
Support:
Developer: go-simpler
License: Mozilla Public License 2.0
sloglint is written in Go. Learn Go with our recommended free books and free tutorials.
Related Software
| Go Linters | |
|---|---|
| revive | Designed as a drop-in replacement for golint |
| golangci-lint | Fast Go linters runner |
| gosec | Security scanner for Go projects |
| Staticcheck | Advanced Go linter |
| go-critic | Opinionated Go source code linter |
| Vet | Examines Go source code and reports suspicious constructs |
| gofumpt | Stricter gofmt |
| gofmt | Formats Go programs |
| goconst | Find repeated Go literals that could be replaced with constants |
| go-ruleguard | Analysis-based Go linter that runs dynamically loaded rules |
| sloglint | Enforce consistent structured logging conventions in Go |
| forbidigo | Go linter for forbidding identifiers |
| godot | Keep source code comments consistent |
| Godoc-Lint | Enforce consistent documentation comments in Go code |
| exhaustive | Check Go switch statements for missing enum cases |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.