logger

package
v0.0.0-...-5b068ba Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(config *Config) (*LevelFilter, *GatedWriter, *LogWriter, io.Writer, bool)

Setup is used to perform setup of serveral logging objects

func ValidateLevelFilter

func ValidateLevelFilter(minLevel LogLevel, filter *LevelFilter) bool

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

Types

type Config

type Config struct {
	LogLevel       string
	EnableSyslog   bool
	SyslogFacility string
}

Config is used to set up logging.

type GatedWriter

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

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

func (*GatedWriter) Flush

func (w *GatedWriter) Flush()

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

func (*GatedWriter) Write

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

Write is

type LevelFilter

type LevelFilter struct {
	Levels   []LogLevel
	MinLevel LogLevel
	Writer   io.Writer
	// contains filtered or unexported fields
}

LevelFilter is an io.Writer that can be used with a logger that will filter out log message

func NewLevelFilter

func NewLevelFilter() *LevelFilter

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

func (*LevelFilter) Check

func (f *LevelFilter) Check(line []byte) bool

Check will check a given line if it would be included in the level filter.

func (*LevelFilter) SetMinLevel

func (f *LevelFilter) SetMinLevel(min LogLevel)

SetMinLevel is used to update the minimum log level

func (*LevelFilter) Write

func (f *LevelFilter) Write(p []byte) (n int, err error)

Write is

type LogHandler

type LogHandler interface {
	HandleLog(string)
}

LogHandler interface is used for clients that want to subscribe to logs

type LogLevel

type LogLevel string

LogLevel is

type LogWriter

type LogWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LogWriter implements io.Writer so it can be used as a log sink.

func NewLogWriter

func NewLogWriter(buf int) *LogWriter

NewLogWriter creates a LogWriter with the given buffer capacity

func (*LogWriter) DeregisterHandler

func (l *LogWriter) DeregisterHandler(lh LogHandler)

DeregisterHandler removes a LogHandler

func (*LogWriter) RegisterHandler

func (l *LogWriter) RegisterHandler(lh LogHandler)

RegisterHandler adds a log handler to receive logs

func (*LogWriter) Write

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

Write is used to accumulate new logs

type Priority

type Priority int

Priority maps to the syslog priority levels

const (
	LOG_EMERG Priority = iota
	LOG_ALERT
	LOG_CRIT
	LOG_ERR
	LOG_WARNING
	LOG_NOTICE
	LOG_INFO
	LOG_DEBUG
)

consts

type SyslogWrapper

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

SyslogWrapper is used to cleanup log messages before writing them to a Syslogger

func (*SyslogWrapper) Write

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

Write is used to implement io.Writer

type Syslogger

type Syslogger interface {
	WriteLevel(Priority, []byte) error
	Write([]byte) (int, error)
	Close() error
}

Syslogger interface is used to write log messages to syslog

func DialLogger

func DialLogger(network, raddr string, p Priority, facility, tag string) (Syslogger, error)

DialLogger is used to construct a new Sysloger that establishes connection to remote syslog server

func NewLogger

func NewLogger(p Priority, facility, tag string) (Syslogger, error)

NewLogger is used to construct a new Syslogger

Jump to

Keyboard shortcuts

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