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
- func P(args ...interface{})
- func PPrep(args ...interface{})
- type Extractor
- type F
- type Flags
- type KeyValue
- type Level
- type LogEntry
- type LogSink
- type LogSinkExt
- 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 ¶
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 ¶
func MakeF(defaults ...interface{}) F
MakeF creates a new log function on a LogSink (which can be another LogFunc or nil) with optional default values
func (F) LogCommitMulti ¶ added in v1.0.13
LogCommitMulti submits a LogEntry into the LogFuncs sink
func (F) LogDefaults ¶
func (lf F) LogDefaults() []interface{}
LogDefaults retrieves the default values provided to LogMakeFunc originally
type Flags ¶
type Flags uint32
Flags should be set at the root log function and modify the verboseness.
const ( ShortTime Flags = 1 << 0 LongTime Flags = 0xffffffff ^ ShortTime HideLevel Flags = 1 << 1 ShowLevel Flags = 0xffffffff ^ HideLevel HideModule Flags = 1 << 2 ShowModule Flags = 0xffffffff ^ HideModule HideCaller Flags = 0xffffffff ^ ShowCaller ShowCaller Flags = 1 << 3 LineSplit Flags = 0xffffffff ^ NoLineSplit NoLineSplit Flags = 1 << 4 HideTime Flags = 0xffffffff ^ ShowTime ShowTime Flags = 1 << 5 RFC5424Format Flags = 1 << 6 // todo )
Flags
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.
func (*LogEntry) AddCallerAttribute ¶
func (le *LogEntry) AddCallerAttribute()
AddCallerAttribute sets a "Caller" value to the function and the line number in the source file
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()
func FmtSink ¶ added in v1.0.11
func FmtSink(defaults ...interface{}) LogSink
FmtSink creates a LogSink printing to fmt.Printf
func SilentSink ¶ added in v1.0.6
func SilentSink(defaults ...interface{}) LogSink
SilentSink creates a LogSink that silently ignores all log entries
func StdSink ¶
func StdSink(defaults ...interface{}) LogSink
StdSink creates a LogSink printing to os.StdOut or os.StdErr depending on Level
func WriterSink ¶
WriterSink creates a LogSink wrapper around a writer with optional defaults"
type LogSinkExt ¶ added in v1.0.13
type LogSinkExt interface {
LogCommitMulti(le []LogEntry)
}
The LogSinkExt 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