logstream

package
v0.0.0-...-5655933 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package logstream provides an interface and implementations of log source streaming. Each log streaming implementation provides an abstraction that makes one pathname look like one perpetual source of logs, even though the underlying file objects might be truncated or rotated, or in the case of pipes have different open/close semantics.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedURLScheme = errors.New("unsupported URL scheme")
	ErrUnsupportedFileType  = errors.New("unsupported file type")
	ErrEmptySocketAddress   = errors.New("socket address cannot be empty, please provide a unix domain socket filename or host:port")
)

Functions

func IsEndOrCancel

func IsEndOrCancel(err error) bool

func SetReadDeadlineOnDone

func SetReadDeadlineOnDone(ctx context.Context, d ReadDeadliner)

Types

type LogStream

type LogStream interface {
	LastReadTime() time.Time // Return the time when the last log line was read from the source
	Stop()                   // Ask to gracefully stop the stream; e.g. stream keeps reading until EOF and then completes work.
	IsComplete() bool        // True if the logstream has completed work and cannot recover.  The caller should clean up this logstream, creating a new logstream on a pathname if necessary.
}

LogStream.

func New

func New(ctx context.Context, wg *sync.WaitGroup, waker waker.Waker, pathname string, lines chan<- *logline.LogLine, oneShot bool) (LogStream, error)

New creates a LogStream from the file object located at the absolute path `pathname`. The LogStream will watch `ctx` for a cancellation signal, and notify the `wg` when it is Done. Log lines will be sent to the `lines` channel. `seekToStart` is only used for testing and only works for regular files that can be seeked.

type ReadDeadliner

type ReadDeadliner interface {
	SetReadDeadline(t time.Time) error
}

Jump to

Keyboard shortcuts

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