log

package
v0.0.0-...-ce94876 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: MIT, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LdJSONFormatter = func() {
	logging.SetFormatter(&PoliteJSONFormatter{})
}

LdJSONFormatter Option formats the event log as line-delimited JSON

View Source
var LevelDebug = func() {
	logging.SetLevel(logging.DEBUG, "")
}

LevelDebug Option sets the log level to debug

View Source
var LevelError = func() {
	logging.SetLevel(logging.ERROR, "")
}

LevelError Option sets the log level to error

View Source
var LevelInfo = func() {
	logging.SetLevel(logging.INFO, "")
}

LevelInfo Option sets the log level to info

View Source
var MaxWriterBuffer = 512 * 1024

MaxWriterBuffer specifies how big the writer buffer can get before killing the writer.

View Source
var TextFormatter = func() {
	logging.SetFormatter(logging.DefaultFormatter)
}

TextFormatter Option formats the event log as human-readable plain-text

View Source
var WriterGroup = NewMirrorWriter()

WriterGroup is the global writer group for logs to output to

Functions

func Configure

func Configure(options ...Option)

Configure applies the provided options sequentially from left to right

Types

type MirrorWriter

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

MirrorWriter implements a WriteCloser which syncs incoming bytes to multiple [buffered] WriteClosers. They can be added with AddWriter().

func NewMirrorWriter

func NewMirrorWriter() *MirrorWriter

NewMirrorWriter initializes and returns a MirrorWriter.

func (*MirrorWriter) Active

func (mw *MirrorWriter) Active() (active bool)

Active returns if there is at least one Writer attached to this MirrorWriter

func (*MirrorWriter) AddWriter

func (mw *MirrorWriter) AddWriter(w io.WriteCloser)

AddWriter attaches a new WriteCloser to this MirrorWriter. The new writer will start getting any bytes written to the mirror.

func (*MirrorWriter) Close

func (mw *MirrorWriter) Close() error

Close closes the MirrorWriter

func (*MirrorWriter) Write

func (mw *MirrorWriter) Write(b []byte) (int, error)

Write broadcasts the written bytes to all Writers.

type Option

type Option func()

Option is a generic function

func Output

func Output(w io.Writer) Option

Output returns an option which sets the the given writer as the new logging backend

type PoliteJSONFormatter

type PoliteJSONFormatter struct{}

PoliteJSONFormatter marshals entries into JSON encoded slices (without overwriting user-provided keys). How polite of it!

func (*PoliteJSONFormatter) Format

func (f *PoliteJSONFormatter) Format(calldepth int, r *logging.Record, w io.Writer) error

Format encodes a logging.Record in JSON and writes it to Writer.

Jump to

Keyboard shortcuts

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