log

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package log provides flexible logging redirection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferLogger

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

BufferLogger stores all log messages. It is primarily useful during startup when the eventual Logger implementation to use is not yet known.

func (*BufferLogger) Log

func (b *BufferLogger) Log(items ...interface{})

Log records a formatted log message for future retrieval.

func (*BufferLogger) WriteTo

func (b *BufferLogger) WriteTo(l Logger)

WriteTo sends recorded log messages to another Logger in order.

type ConsoleLogger

type ConsoleLogger struct{}

ConsoleLogger sends its input directly to the default Go logger tied to os.Stderr.

func (ConsoleLogger) Log

func (l ConsoleLogger) Log(items ...interface{})

Log sends a message to the default Go logger.

type ContextLogger

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

ContextLogger is a logger that prepends a string to each log message.

func (*ContextLogger) Log

func (c *ContextLogger) Log(items ...interface{})

Log prepends the present context from NewContext and passes the resulting log message to the underlying Logger.

type Logger

type Logger interface {
	Log(items ...interface{})
}

Logger is a general-purpose interface for displaying messages.

func NewContext

func NewContext(l Logger, context string) Logger

NewContext creates a new ContextLogger using l as the underlying destination.

type ProxyLogger

type ProxyLogger struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

ProxyLogger is a stable recipient of log messages that can be configured at runtime to forward the messages to different Logger implementations.

func (*ProxyLogger) Log

func (p *ProxyLogger) Log(items ...interface{})

Log forwards its message to the underlying Logger implementation. Panics if called before the first call to SetLogger.

func (*ProxyLogger) SetLogger

func (p *ProxyLogger) SetLogger(l Logger)

SetLogger assigns an underlying Logger implementation to this ProxyLogger.

Jump to

Keyboard shortcuts

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