logutils

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2018 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureEarlyLogging

func ConfigureEarlyLogging()

ConfigureEarlyLogging installs our logging adapters, and enables early logging to screen if it is enabled by either the TYPHA_EARLYLOGSEVERITYSCREEN or TYPHA_LOGSEVERITYSCREEN environment variable.

func ConfigureLogging

func ConfigureLogging(configParams *config.Config)

ConfigureLogging uses the resolved configuration to complete the logging configuration. It creates hooks for the relevant logging targets and attaches them to logrus.

func FormatForSyslog

func FormatForSyslog(entry *log.Entry) string

FormatForSyslog formats logs in a way tailored for syslog. It avoids logging information that is already included in the syslog metadata such as timestamp and PID. The log level _is_ included because syslog doesn't seem to output it by default and it's very useful.

INFO endpoint_mgr.go 434: Skipping configuration of interface because it is oper down.
ifaceName="cali1234"

Types

type BackgroundHook

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

BackgroundHook is a logrus Hook that (synchronously) formats each log and sends it to one or more Destinations for writing ona background thread. It supports filtering destinations on individual log levels. We write logs from background threads so that blocking of the output stream doesn't block the mainline code. Up to a point, we queue logs for writing, then we start dropping logs.

func NewBackgroundHook

func NewBackgroundHook(levels []log.Level, syslogLevel log.Level, destinations []*Destination) *BackgroundHook

func (*BackgroundHook) Fire

func (h *BackgroundHook) Fire(entry *log.Entry) (err error)

func (*BackgroundHook) Levels

func (h *BackgroundHook) Levels() []log.Level

func (*BackgroundHook) Start

func (h *BackgroundHook) Start()

type ContextHook

type ContextHook struct {
}

func (ContextHook) Fire

func (hook ContextHook) Fire(entry *log.Entry) error

func (ContextHook) Levels

func (hook ContextHook) Levels() []log.Level

type Destination

type Destination struct {
	// Level is the minimum level that a log must have to be logged to this destination.
	Level log.Level
	// contains filtered or unexported fields
}

func NewStreamDestination

func NewStreamDestination(
	level log.Level,
	writer io.Writer,
	c chan QueuedLog,
	disableLogDropping bool,
) *Destination

func NewSyslogDestination

func NewSyslogDestination(
	level log.Level,
	writer syslogWriter,
	c chan QueuedLog,
	disableLogDropping bool,
) *Destination

func (*Destination) Close

func (d *Destination) Close()

Close closes the channel to the background goroutine. This is only safe to call if you know that the destination is no longer in use by any thread; in tests, for example.

func (*Destination) LoopWritingLogs

func (d *Destination) LoopWritingLogs()

LoopWritingLogs is intended to be used as a background go-routine. It processes the logs from the channel.

func (*Destination) Send

func (d *Destination) Send(ql QueuedLog) (ok bool)

Send sends a log to the background thread. It returns true on success or false if the channel is blocked.

type Formatter

type Formatter struct{}

Formatter is our custom log formatter, which mimics the style used by the Python version of Typha. In particular, it uses a sortable timestamp and it includes the level, PID, file and line number.

2017-01-05 09:17:48.238 [INFO][85386] endpoint_mgr.go 434: Skipping configuration of
interface because it is oper down. ifaceName="cali1234"

func (*Formatter) Format

func (f *Formatter) Format(entry *log.Entry) ([]byte, error)

type NullWriter

type NullWriter struct{}

NullWriter is a dummy writer that always succeeds and does nothing.

func (*NullWriter) Write

func (w *NullWriter) Write(p []byte) (int, error)

type QueuedLog

type QueuedLog struct {
	Level         log.Level
	Message       []byte
	SyslogMessage string
	WaitGroup     *sync.WaitGroup

	// NumSkippedLogs contains the number of logs that were skipped before this log (due to the
	// queue being blocked).
	NumSkippedLogs uint
}

func (QueuedLog) OnLogDone

func (ql QueuedLog) OnLogDone()

Jump to

Keyboard shortcuts

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