loglint is a Go static analyzer that checks log messages for common quality and safety issues. It is designed to run as a golangci-lint plugin and focuses on message text hygiene and sensitive data leaks.
| # | Rule | Description |
|---|---|---|
| 1 | lowercase_start | Log messages must start with a lowercase letter |
| 2 | english_only | Log messages must contain English text only |
| 3 | no_special_chars | Log messages must not contain emojis or any punctuation/special characters |
| 4 | no_sensitive_data | Log messages must not include sensitive data (by keyword matching) |
log/slog(standard structured logger)go.uber.org/zap(Logger and SugaredLogger)log(standard library logger)
make buildmake pluginBuild:
make buildRun:
./loglint ./...You can also pass -config or -fix:
./loglint -config /path/to/.loglint.yml ./...
./loglint -fix ./...- Build the plugin:
make plugin- Add it to
.golangci.yml:
linters-settings:
custom:
loglint:
path: ./loglint.so
description: "Linter for checking log messages"
original-url: github.com/alchemmist/loglint
linters:
enable:
- loglint- Run:
golangci-lint runCreate a configuration file in your project root:
.loglint.yml.loglint.yaml.loglint.json
The analyzer searches the current directory and all parent directories.
rules:
lowercase_start: true
english_only: true
no_special_chars: true
no_sensitive_data: true
patterns:
sensitive_keywords:
- password
- secret
- token
- api_key
- private_key
- my_custom_secret{
"rules": {
"lowercase_start": true,
"english_only": true,
"no_special_chars": true,
"no_sensitive_data": true
},
"patterns": {
"sensitive_keywords": ["password", "secret", "token", "api_key", "private_key"]
}
}The analyzer can apply suggested fixes for:
- Rule 1: convert the first character to lowercase
- Rule 3: remove emojis/special characters
Use the -fix flag when running through golangci-lint.
- Rules 1-3 only run when the log message is a string literal.
- Rule 4 scans identifiers inside the message expression and subsequent arguments for sensitive keywords.
# Install dev tools
make tools
# Run tests
make test
# Run tests with coverage report
make test-cover
# Run vet, formatting checks, golangci-lint, and staticcheck
make check
# Format the codebase (gofmt + gofumpt)
make fmt
# Clean build artifacts and local caches
make cleancmd/ # Standalone CLI entrypoint (stub)
pkg/analyzer/ # Analyzer implementation, rules, and config
plugin/ # golangci-lint plugin
testdata/ # Analyzer test fixtures
MIT