Documentation ¶
Overview ¶
Package logfunk provides a concise, pluggable API for structured logging.
logfunk uses custom type arguments to set additional logging options.
See README.md for details.
Index ¶
- Constants
- type Extractor
- type F
- type Flags
- type KeyValue
- type Level
- type LogEntry
- type LogSink
- type Logger
- func (l *Logger) Fatal(v ...interface{})
- func (l *Logger) Fatalf(format string, v ...interface{})
- func (l *Logger) Fatalln(v ...interface{})
- func (l *Logger) Flags() int
- func (l *Logger) Output(calldepth int, s string) error
- func (l *Logger) Panic(v ...interface{})
- func (l *Logger) Panicf(format string, v ...interface{})
- func (l *Logger) Panicln(v ...interface{})
- func (l *Logger) Prefix() string
- func (l *Logger) Print(v ...interface{})
- func (l *Logger) Printf(format string, v ...interface{})
- func (l *Logger) Println(v ...interface{})
- func (l *Logger) SetFlags(flag int)
- func (l *Logger) SetOutput(w io.Writer)
- func (l *Logger) SetPrefix(prefix string)
- func (l *Logger) Writer() io.Writer
- type MinLevel
- type Module
Constants ¶
const ( // ExtractSink has to be followed by a *LogSink argument that gets set to the parent LogSink instance for this log function. ExtractSink = Extractor(0) // ExtractDefaults has to be followed by a *[]interface{} argument that gets set to the default parameters for this log function. ExtractDefaults = Extractor(1) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor int
Extractor values are special log arguments that cause context information to be returned from a log function.
type F ¶
type F func(args ...interface{})
F is a logging function with some twists. All instances of F should be created through MakeF(). F implements the LogSink interface for stacking.
func MakeF ¶
MakeF creates a new log function on a LogSink (which can be another LogFunc or nil) with optional default values
func (F) GetSink ¶
GetSink returns the LogSink that was used to create this LogFunc
func (F) LogCommit ¶
LogCommit submits a LogEntry into the LogFuncs sink
type Flags ¶
type Flags uint32
Flags should be set at the root log function and modify the verboseness.
type KeyValue ¶
KeyValue captures a named value for structured logging
type Level ¶
type Level int
Level specifies a severity level for a log message. Possible values are Spam, Debug, Info, Warn, Error and Fatal.
type LogEntry ¶
type LogEntry struct { Time timestamp.TS Level Level Module string Text string Flags Flags Attr map[string]string }
A LogEntry captures all information for a single log line.
type LogSink ¶
type LogSink interface { LogCommit(le LogEntry) LogDefaults() []interface{} }
The LogSink interface processes LogEntry values and provides default parameters. It is implemented by all logfunk.F returned from logfunk.MakeF()
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger mimics the log.Logger structure
func NewLogger ¶
NewLogger creates a new log.Logger-compatible Logger wrapping f
func (*Logger) Fatalf ¶
Fatalf mimics log.Logger
func (*Logger) Output ¶
Output mimics log.Logger
func (*Logger) Panicf ¶
Panicf mimics log.Logger
func (*Logger) Prefix ¶
Prefix mimics log.Logger, returns an empty string
func (*Logger) Printf ¶
Printf mimics log.Logger
func (*Logger) SetFlags ¶
SetFlags mimics log.Logger, but is a nop
func (*Logger) SetOutput ¶
SetOutput mimics log.Logger, but is a nop
func (*Logger) SetPrefix ¶
SetPrefix mimics log.Logger, but is a nop