Documentation
¶
Index ¶
Constants ¶
View Source
const ( // TraceField defined the key for the field to store trace duration. TraceField = "trace" // CallerField defines the key for the caller information. CallerField = "caller" // ErrorField can be used by handlers to represent the error in the data field collection. ErrorField = "error" )
View Source
const (
// ContextField defines the field name to store context.
ContextField = "context"
)
Variables ¶
View Source
var ( // ExitProcessor is executed on Log(LevelFatal) to terminate the application. ExitProcessor = func(message string) { os.Exit(1) } )
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry interface { // Time represents entry time stamp. Time() time.Time // Level represents the log level. Level() slf.Level // Message reresents the log formatted message. Message() string // Error, if present, represents the error to be logged along with the message and the fields. Error() error // Fields represents structured log information. Fields() map[string]interface{} }
Entry represents a log entry for structured logging. Entries are only created when the requested level is same or above the minimum log level of the context root.
type EntryHandler ¶
type EntryHandler interface { // Handle processes a filtered log entry (must not write to the entry field map, which is // read concurrently by all handlers). Handle(Entry) error }
EntryHandler processes filtered log entries in independent go-routines.
type LogFactory ¶
type LogFactory interface { slf.LogFactory SetLevel(level slf.Level, contexts ...string) SetCallerInfo(callerInfo slf.CallerInfo, contexts ...string) AddEntryHandler(handler EntryHandler) SetEntryHandlers(handlers ...EntryHandler) Contexts() map[string]slf.StructuredLogger SetConcurrent(conc bool) }
LogFactory extends the SLF LogFactory interface with a series of methods specific to the slog implementation.
Directories
¶
Path | Synopsis |
---|---|
Package basic provides a basic text/terminal log entry handler for slog.
|
Package basic provides a basic text/terminal log entry handler for slog. |
Package json provides a JSON log entry handler formatting JSON into the given Writer.
|
Package json provides a JSON log entry handler formatting JSON into the given Writer. |
Click to show internal directories.
Click to hide internal directories.