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 ¶
Functions ¶
func IsEndOrCancel ¶
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.