Documentation ¶
Overview ¶
Package log is an interface for structured logging.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultLevel Level = InfoLevel DefaultOutputName = "log.json" Levels = map[Level]string{ DebugLevel: "debug", InfoLevel: "info", WarnLevel: "warn", ErrorLevel: "error", FatalLevel: "fatal", } )
Functions ¶
Types ¶
type Event ¶
type Event struct { Level Level `json:"level"` Fields Fields `json:"fields"` Timestamp int64 `json:"timestamp"` Message string `json:"message"` }
Event represents a single log event
func (*Event) MarshalJSON ¶
type Logger ¶
type Logger interface { // Logger interface Debug(args ...interface{}) Info(args ...interface{}) Error(args ...interface{}) Fatal(args ...interface{}) // Formatted logger Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) // Specify your own levels Log(l Level, args ...interface{}) Logf(l Level, format string, args ...interface{}) // Returns with extra fields WithFields(f Fields) Logger }
type Output ¶
type Output interface { // Send an event Send(*Event) error // Flush any buffered events Flush() error // Discard the output Close() error // Name of output String() string }
An output represents a file, indexer, syslog, etc
func NewOutput ¶
func NewOutput(opts ...OutputOption) Output
type OutputOption ¶
type OutputOption func(o *OutputOptions)
func OutputName ¶
func OutputName(name string) OutputOption
type OutputOptions ¶
type OutputOptions struct { // filepath, url, etc Name string }
Click to show internal directories.
Click to hide internal directories.