Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorState ¶
type ErrorState int
ErrorState defines a set of concrete error states that can be encountered by the LogManager.
const ( ErrorStateUnknown ErrorState = iota ErrorStateCancelled ErrorStateFSWatcher ErrorStateFilePath ErrorStateFileNotExist ErrorStateFileRemoved ErrorStateFileIO ErrorStateEndOfStream ErrorStateInternal )
func (ErrorState) String ¶
func (es ErrorState) String() string
String() returns a string representation of the ErrorState.
type LogManager ¶
type LogManager struct {
// contains filtered or unexported fields
}
LogManager is used to watch one of more log files for changes and consume the data line by line to be passed as a byte slice to a consumer channel.
func NewLogManager ¶
func NewLogManager(ctx context.Context, options ...Option) (*LogManager, error)
NewLogManager creates a new LogManager
func (*LogManager) AddLogFile ¶
func (lm *LogManager) AddLogFile(lp string) (<-chan []byte, <-chan error, error)
AddLogFile adds a log file to the LogManager and starts its data processor. Two channels are returned, for data and errors respectively and an error if the Add operation fails completely.
The data channel will return a byte slice for each delimited line of the log file. The default delimeter is a newline.
The error channel will return any errors encountered while processing the log file which can be both critical and non-critical. When a critical error is encountered, the data processor will stop and the log file will be removed from the LogManager. Non-critical errors will be logged and the data processor will continue. Both channels will be closed when all operations have completed or critical errors have been encountered.
func (*LogManager) GetLogFile ¶
func (lm *LogManager) GetLogFile(fp string) (<-chan []byte, <-chan error, error)
GetLogFile returns the data and error channels for a log file being watched by the LogManager.
func (*LogManager) GetLogFiles ¶
func (lm *LogManager) GetLogFiles() []string
GetLogFiles returns a slice of log file paths being watched by the LogManager.
func (*LogManager) RemoveLogFile ¶
func (lm *LogManager) RemoveLogFile(lp string) error
RemoveLogFile removes a log file from the LogManager and stops its data processor.
type LogWhaleError ¶
type LogWhaleError struct { State ErrorState Msg string Cause error }
func NewLogWhaleError ¶
func NewLogWhaleError(state ErrorState, msg string, cause error) *LogWhaleError
func (*LogWhaleError) Error ¶
func (e *LogWhaleError) Error() string
Error satisfies the error interface.
func (*LogWhaleError) Unwrap ¶
func (e *LogWhaleError) Unwrap() error
Unwrap satisfies the Wrapper interface. It allows the LogWhaleError to work with and errors.As.
type Option ¶
type Option func(*LogManager) error
Option is a function that can be passed to NewLogManager to configure it.