logevent

package module
v0.0.0-...-639fd54 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

README

logevent - A structured event logger abstraction

We've moved to https://github.com/asecurityteam/logevent.

This repository is read-only and maintained to support existing users. New development will happen in the new location.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, logger Logger) context.Context

NewContext installs a Logger.

Types

type Config

type Config struct {
	// Level at which to log. Defaults to DEBUG.
	// Acceptable are ERROR, WARN, INFO, and DEBUG.
	Level string
	// HumanReadable toggles the JSON format off in favour of a colourised
	// log formatted for human readers.
	HumanReadable bool
	// Output defines to where logs are written. The default is os.Stdout.
	Output io.Writer
}

Config records the requested settings for a logger for use with New().

type Logger

type Logger interface {
	// Debug will emit the event with level DEBUG.
	Debug(event interface{})
	// Info will emit the event with level INFO.
	Info(event interface{})
	// Warn will emit the event with level WARN
	Warn(event interface{})
	// Error will emit the event with level ERROR.
	Error(event interface{})
	// SetField applies a contextual annotation to all
	// future events logged with this logger.
	SetField(name string, value interface{})
	// Copy the logger of use in some other context.
	Copy() Logger
}

Logger is a logging system abstraction that supports levelled, strictly structured log emissions.

func FromContext

func FromContext(ctx context.Context) Logger

FromContext fetches a Logger.

func New

func New(c Config) Logger

New creates an instance of a Logger using the default backend.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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