slogkv

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 6 Imported by: 0

README

yze-go-slogkv

A yze analyzer (category logging) that reports a leveled slog call (slog.Info/Warn/Error/Debug, or the same methods on a *slog.Logger) whose trailing key/value arguments are unpaired (odd count) or use a non-constant-string key, per the gomatic structured-logging standard.

Calls that pass any slog.Attr argument are intentionally not checked — mixing pre-built attributes with loose pairs is a valid, harder-to-verify shape, so the analyzer skips it rather than risk a false positive. The Context/Log/LogAttrs variants are out of scope for v1.

  • Rule: yze/slogkv
  • Library: exports Analyzer (a standard go/analysis analyzer) and Registration for the yze aggregator and stickler runner.
  • Binary: cmd/yze-go-slogkv runs it standalone (text/-json, and as a go vet -vettool).

Built on the go-yze framework.

Documentation

Overview

Package slogkv provides a go/analysis analyzer enforcing the gomatic structured- logging standard: a leveled slog call (slog.Info/Warn/Error/Debug, or the same methods on a *slog.Logger) passes its attributes as constant-string key/value pairs — an even number of trailing arguments whose keys are constant strings.

Calls that pass any slog.Attr argument are intentionally not checked: mixing pre-built attributes with loose pairs is a valid, harder-to-verify shape, so the analyzer skips it rather than risk a false positive.

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:     "slogkv",
	Doc:      "reports leveled slog calls whose key/value arguments are unpaired or use a non-constant key",
	Requires: []*analysis.Analyzer{inspect.Analyzer},
	Run:      run,
}

Analyzer reports malformed key/value arguments to leveled slog calls.

View Source
var Registration = goyze.Registration{
	Name:       "slogkv",
	Categories: []goyze.Category{"logging"},
	URL:        "https://docs.gomatic.dev/yze/slogkv",
	Analyzer:   Analyzer,
}

Registration declares this analyzer to the yze framework.

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd
yze-go-slogkv command
Command yze-go-slogkv runs the slogkv analyzer as a standalone go/analysis checker (text and -json output, and usable as a `go vet -vettool`).
Command yze-go-slogkv runs the slogkv analyzer as a standalone go/analysis checker (text and -json output, and usable as a `go vet -vettool`).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL