log

package
v0.2402.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Overview

Package log provides utilities for watching log files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

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

Watcher is a log file watcher.

func NewWatcher

func NewWatcher(cfg *WatcherConfig) (*Watcher, error)

NewWatcher creates a new log watcher.

func (*Watcher) Cleanup

func (l *Watcher) Cleanup()

Cleanup stops watching the log.

func (*Watcher) Errors

func (l *Watcher) Errors() <-chan error

Errors returns a channel that is used to receive any errors encountered by the handlers while watching the log.

func (*Watcher) Name

func (l *Watcher) Name() string

Name returns the log watcher name.

type WatcherConfig

type WatcherConfig struct {
	Name string
	File string

	Handlers []WatcherHandler
}

WatcherConfig is a log file watcher configuration.

type WatcherHandler

type WatcherHandler interface {
	// Line is called for each processed line.
	Line(string) error

	// Finish is called after the log file has been closed.
	Finish() error
}

WatcherHandler is a log file watcher handler.

type WatcherHandlerFactory

type WatcherHandlerFactory interface {
	// New will create and return a WatcherHandler ready for use.
	New() (WatcherHandler, error)
}

WatcherHandlerFactory is a factory interface for log file watcher handlers.

func AssertContains

func AssertContains(text, message string) WatcherHandlerFactory

AssertContains returns a factory of log handlers which check that the given text is contained in the log output.

func AssertJSONContains

func AssertJSONContains(key, value, message string) WatcherHandlerFactory

AssertJSONContains returns a factory of log handlers which check that the given key/value pair is contained encoded as JSON in the log output.

func AssertNotContains

func AssertNotContains(text, message string) WatcherHandlerFactory

AssertNotContains returns a factory of log handlers which check that the given text is not contained in the log output.

func AssertNotJSONContains

func AssertNotJSONContains(key, value, message string) WatcherHandlerFactory

AssertNotJSONContains returns a factory of log handlers which check that the given key/value pair is not contained encoded as JSON in the log output.

Jump to

Keyboard shortcuts

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