log

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JsonFormat format = iota
	LogfmtFormat
)

Variables

View Source
var (
	// DefaultOutput is the default io.Writer where log messages are written (os.Stdout).
	DefaultOutput = os.Stdout

	// DefaultFormat is the default log format (json)
	// Available formats: json, logfmt
	DefaultFormat = JsonFormat

	// DefaultFallbackLevel is the default fallback level used in messages when a level is not defined.
	DefaultFallbackLevel level.Value = level.InfoValue()
)

Functions

func NewLogger

func NewLogger(opts ...LogOption) log.Logger

NewLogger returns a new Logger.

func ParseFormat

func ParseFormat(formatName string) (format, error)

ParseFormat parses a string format name and returns the format or an error if the format is invalid.

Types

type LogOption

type LogOption func(o *options)

LogOption configures the option list.

func Conditional added in v0.2.0

func Conditional(c bool, op LogOption) LogOption

Conditional applies an option if the condition is true. This is useful to avoid using conditional logic when building the option list.

func Context

func Context(c []interface{}) LogOption

Context sets the default context.

func Debug

func Debug(d bool) LogOption

Debug enables/disables debug level.

func FallbackLevel

func FallbackLevel(l level.Value) LogOption

FallbackLevel sets the default fallback level.

func Format

func Format(f format) LogOption

Format sets the log format in the logger.

func FormatString

func FormatString(sf string) LogOption

FormatString accepts a string and tries to parse it as a log format. If the string cannot be parsed as a format, this method panics.

Other than that it behaves like Format.

func Output

func Output(ou io.Writer) LogOption

Output sets the io.Writer output.

func With

func With(kv ...interface{}) LogOption

With appends to the default context.

Jump to

Keyboard shortcuts

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