logsafe

package
v1.63.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package logsafe makes a value safe to write into a log line.

A log is read by people and by machines that split it into records. A value carrying a newline can therefore forge a record — a refusal that looks like a success, an identity that was never there — and the values most worth logging are exactly the ones that came from outside: an address a gateway forwarded, a path a caller chose, the text of an error built from either.

Structured handlers escape these already, which is why nothing here has ever been forgeable in practice. This makes it true by construction instead of by the handler's choice, and names the intent where it can be seen.

Index

Constants

View Source
const Limit = 256

Limit is how much of a value is kept. Long enough for an address, a method name or a sentence; short enough that one field cannot bury a record.

Variables

This section is empty.

Functions

func Error

func Error(err error) string

Error is Value over an error's message. Errors are worth their own call because the interesting ones are built from the input that caused them: a directory read that failed carries the address it was asked about.

func Value

func Value(text string) string

Value returns text that cannot forge a log record.

Types

This section is empty.

Jump to

Keyboard shortcuts

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