Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContextField ¶
func Bool ¶
func Bool(key string, b bool) ContextField
func Int ¶
func Int(key string, i int) ContextField
func Str ¶
func Str(key, val string) ContextField
func Uint ¶
func Uint(key string, i uint) ContextField
type Event ¶
type Event interface {
// Msg sends the Event with msg added as the message field if not empty.
Msg(msg string)
// Str adds the field key with val as a string to the Event.
Str(key, val string) Event
// Err adds the field "error" with serialized err to the Event.
// If err is nil, no field is added.
Err(err error) Event
// Bool adds the field key with val as a bool to the Event.
Bool(key string, b bool) Event
// Int adds the field key with i as a int to the Event.
Int(key string, i int) Event
// Uint adds the field key with i as a uint to the Event.
Uint(key string, i uint) Event
// Stringer adds the field key with val.String() (or null if val is nil)
// to the Event.
Stringer(key string, val fmt.Stringer) Event
// IsEnabled returns true if the Event is enabled for the given log level
// It is helpful when you want to avoid expensive operations on formatting
// the log fields.
IsEnabled() bool
}
Event represents a log event. It is instanced by one of the level method of Logger and finalized by the Msg method.
type Level ¶
type Level int8
Level is the type of log level
const ( // LevelUnknown is a default value for unknown log level LevelUnknown Level = iota - 1 // LevelNoLog is the lowest level of logging, no logs are generated LevelNoLog // LevelError is the level of logging only for errors LevelError // LevelWarn is the level of logging for warnings LevelWarn // LevelInfo is the lowest of logging for informational messages LevelInfo // LevelDebug is the level of logging for debug messages LevelDebug // LevelTrace is the highest level of logging LevelTrace )
type Logger ¶
type Logger interface {
// WithOutput duplicates the current logger and sets w as its output.
WithOutput(w io.Writer) Logger
// Level creates a child logger with the minimum accepted level set to level.
WithLevel(lvl Level) Logger
// WithOutput duplicates the current logger and adds context fields to it.
With(...ContextField) Logger
// Trace starts a new message with trace level.
// You must call Msg on the returned event in order to send the event.
Trace() Event
// Debug starts a new message with debug level.
// You must call Msg on the returned event in order to send the event.
Debug() Event
// Info starts a new message with info level.
// You must call Msg on the returned event in order to send the event.
Info() Event
// Warn starts a new message with warn level.
// You must call Msg on the returned event in order to send the event.
Warn() Event
// Error starts a new message with error level.
// You must call Msg on the returned event in order to send the event.
Error() Event
}
Logger is used to log SecDebugLog messages This interface is highly inspired in github.com/rs/zerolog logger and the aim is to avoid allocations while logging.
func DefaultWithPrinterFactory ¶
func DefaultWithPrinterFactory(f PrinterFactory) Logger
DefaultWithPrinterFactory returns a default logger that writes to stderr with a given printer factory. It is useful when you need to abstract the printer.
type PrinterFactory ¶
Click to show internal directories.
Click to hide internal directories.