Documentation
¶
Index ¶
Constants ¶
View Source
const (
// TransactionIDKey is the key name being set in the logger
TransactionIDKey = "transaction_id"
)
Variables ¶
This section is empty.
Functions ¶
func GetTransactionID ¶ added in v1.6.0
GetTransactionID retrieves the transaction id after `SetTransactionID` has been called. It will return an empty string if no transaction id has been set.
func NewContext ¶
NewContext installs a Logger.
func SetTransactionID ¶ added in v1.6.0
SetTransactionID sets a transaction id string in the logger and context. If an empty string is passed in, then a randomly generated uuid will be used as the transaction id.
Types ¶
type Config ¶
type Config struct {
// Level at which to log. Defaults to DEBUG.
// Acceptable are ERROR, WARN, INFO, and DEBUG.
Level string
// HumanReadable toggles the JSON format off in favor of a colorised
// log formatted for human readers.
HumanReadable bool
// Output defines to where logs are written. The default is os.Stdout.
Output io.Writer
}
Config records the requested settings for a logger for use with New().
type Logger ¶
type Logger interface {
// Debug will emit the event with level DEBUG.
Debug(event interface{})
// Info will emit the event with level INFO.
Info(event interface{})
// Warn will emit the event with level WARN
Warn(event interface{})
// Error will emit the event with level ERROR.
Error(event interface{})
// SetField applies a contextual annotation to all
// future events logged with this logger.
SetField(name string, value interface{})
// Copy the logger of use in some other context.
Copy() Logger
}
Logger is a logging system abstraction that supports leveled, strictly structured log emissions.
Click to show internal directories.
Click to hide internal directories.
