entry_size_guard

package
v1.18.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// Cloud Logging rejects entries above 256 KiB outright — they vanish rather
	// than being truncated — so oversized entries must be reduced before being
	// written. The default leaves headroom for agent-added metadata.
	DefaultEntryLimit = 200 * 1024

	// When an entry exceeds the entry limit, strings above this length are
	// truncated.
	DefaultStringLimit = 4 * 1024

	// TruncatedKey marks entries that were reduced to fit the entry limit.
	TruncatedKey = "log.truncated"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	Writer      io.Writer
	EntryLimit  int
	StringLimit int
}

Writer guards an underlying writer against oversized log entries. Each Write call is expected to carry one entry (as slog handlers do). Entries within the limit pass through untouched; oversized ones are reduced by truncating long strings throughout the entry, and, failing that, by falling back to a minimal entry retaining the time, severity, message and error message.

func New

func New(writer io.Writer) *Writer

func (*Writer) Write

func (w *Writer) Write(entry []byte) (int, error)

Jump to

Keyboard shortcuts

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