Help us shape the future of Go! Take the 2026 Go Developer Survey

log

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxBodySize is the default maximum size for body content before truncation
	DefaultMaxBodySize = 2048
	// DefaultPreviewSize is the default size of the preview shown for truncated content
	DefaultPreviewSize = 500
)

Variables

This section is empty.

Functions

func TruncateBody added in v0.7.0

func TruncateBody(body string, maxSize, previewSize int) string

TruncateBody truncates a string body if it exceeds maxSize. Returns original string if within limit, otherwise returns truncated format: [LARGE_BODY: truncated, size: %d bytes, preview: %s...]

func TruncateBodyDefault added in v0.7.0

func TruncateBodyDefault(body string) string

TruncateBodyDefault truncates a string body using default size limits.

Types

type IOLogger

type IOLogger struct {
	// contains filtered or unexported fields
}

IOLogger is a wrapper around io.Reader and io.Writer that can be used to log the data being read and written from the underlying streams

func NewIOLogger

func NewIOLogger(r io.Reader, w io.Writer, logger *slog.Logger) *IOLogger

NewIOLogger creates a new IOLogger instance

func (*IOLogger) Read

func (l *IOLogger) Read(p []byte) (n int, err error)

Read reads data from the underlying io.Reader and logs it.

func (*IOLogger) Write

func (l *IOLogger) Write(p []byte) (n int, err error)

Write writes data to the underlying io.Writer and logs it.

Jump to

Keyboard shortcuts

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