sink

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPretty

func NewPretty(w io.Writer) io.Writer

NewPretty wraps w with an NDJSON pretty-printer.

Each newline-delimited JSON record is reformatted into a single human-readable line with a dimmed timestamp, a colored level, the message, and remaining fields as key=value pairs. Lines that fail to parse as JSON pass through unchanged. Safe for concurrent use.

Drop-in for any NDJSON producer — jsoncore, the zap/zerolog/slog contribs, or any other backend that writes JSON-per-line.

func Stderr

func Stderr() io.Writer

func Stdout

func Stdout() io.Writer

Types

type Discard

type Discard struct{}

func NewDiscard

func NewDiscard() Discard

func (Discard) Close

func (Discard) Close() error

func (Discard) Sync

func (Discard) Sync() error

func (Discard) Write

func (Discard) Write(p []byte) (int, error)

type File

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

func OpenFile

func OpenFile(path string, opts ...FileOption) (*File, error)

func (*File) Close

func (f *File) Close() error

func (*File) Sync

func (f *File) Sync() error

func (*File) Write

func (f *File) Write(p []byte) (int, error)

type FileConfig

type FileConfig struct {
	MaxSize    int64
	MaxBackups int
	Compress   bool
	Mode       os.FileMode
	Clock      func() time.Time
}

func DefaultFileConfig

func DefaultFileConfig() FileConfig

type FileOption

type FileOption func(*FileConfig)

func WithClock

func WithClock(clock func() time.Time) FileOption

func WithCompress

func WithCompress(enabled bool) FileOption

func WithFileMode

func WithFileMode(mode os.FileMode) FileOption

func WithMaxBackups

func WithMaxBackups(count int) FileOption

func WithMaxSize

func WithMaxSize(bytes int64) FileOption

type Locked

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

func NewLocked

func NewLocked(writer io.Writer) *Locked

func (*Locked) Close

func (l *Locked) Close() error

func (*Locked) Sync

func (l *Locked) Sync() error

func (*Locked) Write

func (l *Locked) Write(p []byte) (int, error)

type Multi

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

func NewMulti

func NewMulti(writers ...io.Writer) Multi

func (Multi) Close

func (m Multi) Close() error

func (Multi) Sync

func (m Multi) Sync() error

func (Multi) Write

func (m Multi) Write(p []byte) (int, error)

type Writer

type Writer struct {
	io.Writer
}

Writer is a small named wrapper for io.Writer sinks.

func NewWriter

func NewWriter(writer io.Writer) Writer

func (Writer) Close

func (w Writer) Close() error

func (Writer) Sync

func (w Writer) Sync() error

Jump to

Keyboard shortcuts

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