Documentation
¶
Overview ¶
Package filch is a file system queue that pilfers your stderr. (A FILe CHannel that filches.)
Index ¶
Constants ¶
const DefaultMaxFileSize = 50 << 20
const DefaultMaxLineSize = 64 << 10
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filch ¶
type Filch struct {
// OrigStderr is the original [os.Stderr] if [Options.ReplaceStderr] is specified.
// Writing directly to this avoids writing into the Filch buffer.
// Otherwise, it is nil.
OrigStderr *os.File
// contains filtered or unexported fields
}
A Filch uses two alternating files as a simplistic ring buffer.
func (*Filch) ExpVar ¶ added in v1.94.0
ExpVar returns a metrics.Set with metrics about the buffer.
counter_write_calls: Total number of calls to Filch.Write (excludes calls when file is closed).
counter_read_calls: Total number of calls to Filch.TryReadLine (excludes calls when file is closed or no bytes).
counter_rotate_calls: Total number of calls to rotate the log files (excludes calls when there is nothing to rotate to).
counter_call_errors: Total number of calls returning errors.
counter_write_bytes: Total number of bytes written (includes bytes filched from stderr).
counter_read_bytes: Total number of bytes read (includes bytes filched from stderr).
counter_filched_bytes: Total number of bytes filched from stderr.
counter_dropped_bytes: Total number of bytes dropped (includes bytes filched from stderr and lines too long to read).
gauge_stored_bytes: Current number of bytes stored on disk.
func (*Filch) TryReadLine ¶
TryReadline implements the logtail.Buffer interface.
type Options ¶
type Options struct {
// ReplaceStderr specifies whether to filch [os.Stderr] such that
// everything written there appears in the [Filch] buffer instead.
// In order to write to stderr instead of writing to [Filch],
// then use [Filch.OrigStderr].
ReplaceStderr bool
// MaxLineSize is the maximum line size that could be encountered,
// including the trailing newline. This is enforced as a hard limit.
// Writes larger than this will be rejected. Reads larger than this
// will report an error and skip over the long line.
// If zero, the [DefaultMaxLineSize] is used.
MaxLineSize int
// MaxFileSize specifies the maximum space on disk to use for logs.
// This is not enforced as a hard limit, but rather a soft limit.
// If zero, then [DefaultMaxFileSize] is used.
MaxFileSize int
}