stdlog

package module
v0.2.23 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 5 Imported by: 0

README

Documentation

Overview

Package stdlog provides a go/analysis analyzer enforcing the gomatic Go logging standard: the standard library "log" package is forbidden in favor of structured logging with "log/slog".

One import of it is not a way to log and is not reported: the standard library's own bridge. `slog.NewLogLogger` hands back a *log.Logger, because the fields that take a logger were typed before log/slog existed and still are — http.Server.ErrorLog and httputil.ReverseProxy.ErrorLog among them. A file that imports log ONLY to name that type, and imports log/slog too, is doing what this standard asks; telling it to "use log/slog" named an edit that does not exist. A single log.Printf, log.New or log.Fatal puts the file back under the rule. See [bridgesToSlog].

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "stdlog",
	Doc:  "reports imports of the standard log package, which the gomatic standard replaces with log/slog",
	Run:  run,
}

Analyzer reports imports of the standard "log" package.

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

Registration declares this analyzer to the yze framework. The category is "logging", shared with yze/slogkv, so narrowing a run to the logging standard yields the whole standard rather than half of it; "data" was this rule's tag until then and named the wrong subject — it is jsontag's, about serialization.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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