loghelper

package
v0.0.0-...-174afc0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LevelFilter

func LevelFilter() *logutils.LevelFilter

LevelFilter returns a LevelFilter that is configured with the log levels that we use.

func ValidateLevelFilter

func ValidateLevelFilter(minLevel logutils.LogLevel, filter *logutils.LevelFilter) bool

ValidateLevelFilter verifies that the log levels within the filter are valid.

Types

type LogHandler

type LogHandler interface {
	HandleLog(string)
}

LogHandler interface is used for clients that want to subscribe to logs, for example to stream them over an IPC mechanism

type LogRegistrar

type LogRegistrar struct {
	// embedded mutex
	sync.Mutex
	// contains filtered or unexported fields
}

LogRegistrar can be used as a log sink. It maintains a circular buffer of logs, and a set of handlers to which it can stream the logs to.

LogRegistrar implements:

  1. io.Writer interface

LogRegistrar composes:

  1. LogHandler interface

func NewLogRegistrar

func NewLogRegistrar(buf int) *LogRegistrar

NewLogRegistrar creates a LogRegistrar with the given buffer capacity

func (*LogRegistrar) DeregisterHandler

func (l *LogRegistrar) DeregisterHandler(lh LogHandler)

DeregisterHandler removes a LogHandler and prevents more invocations

func (*LogRegistrar) RegisterHandler

func (l *LogRegistrar) RegisterHandler(lh LogHandler)

RegisterHandler adds a log handler to receive logs, and sends the last buffered logs to the handler

func (*LogRegistrar) Write

func (l *LogRegistrar) Write(p []byte) (n int, err error)

Write is used to accumulate new logs

type SyslogWriter

type SyslogWriter struct {
	GSyslog gsyslog.Syslogger
	LFilter *logutils.LevelFilter
}

SyslogWriter is used to cleaup log messages before writing them to a Syslogger.

Implements the io.Writer interface.

func (*SyslogWriter) Write

func (s *SyslogWriter) Write(p []byte) (int, error)

Write is used to implement io.Writer

type Writer

type Writer struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

Writer is an io.Writer implementation that buffers all of its data into an internal buffer until it is told to let data through.

func (*Writer) Flush

func (w *Writer) Flush()

Flush tells the Writer to flush any buffered data and to stop buffering.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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