Documentation
¶
Overview ¶
Package ulog is the antidote to modern loggers.
ulog only logs JSON formatted output. Structured logging is the only good logging.
ulog does not have log levels. If you don't want something logged, don't log it.
ulog does support setting fields in context. Useful for building a log context over the course of an operation.
Index ¶
Constants ¶
const ( DefaultTimestampKey = "ts" DefaultMessageKey = "msg" )
Variables ¶
var (
DefaultWriter = os.Stderr
)
Functions ¶
Types ¶
type ULog ¶
type ULog struct {
Writer io.Writer
TimestampKey, MessageKey string `json:"-"`
// contains filtered or unexported fields
}
ULog is the antidote to modern loggers
func WithKeyNames ¶
WithKeyNames returns a copy of the ULog instance with the provided key names for timestamp and message keys.
func WithWriter ¶
WithWriter returns a copy of the standard ULog instance configured to write to the given writer
func (ULog) With ¶
With returns a copy of the ULog instance with the provided fields preset for every subsequent call.
func (ULog) WithKeyNames ¶
WithKeyNames returns a copy of the ULog instance with the provided key names for timestamp and message keys.
func (ULog) Write ¶
Write a JSON message to the configured writer or os.Stderr.
Includes the message with the key `msg`. Includes the timestamp with the key `ts`. The timestamp field is always first and the message second.
Fields in context will not be overridden. ULog will log the same key multiple times if it is set multiple times. If you don't want that, don't specify it multiple times.