Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MustContext ¶
MustContext extends log.Context to implement MustLogger.
Example ¶
mustContext := NewMustContext(&errLogger{}, func(err error, keyvals ...interface{}) { fmt.Println("failed to log:", err) }) mustContext.Must("k", "v") mustContext.Must(poison, "poison") mustContext = mustContext.With("withK", "withV") mustContext.Must("k", "v") mustContext.Must(poison, "poison") mustContext = mustContext.WithPrefix("prefixK", "prefixV") mustContext.Must("k", "v") mustContext.Must(poison, "poison")
Output: k v failed to log: poisoned withK withV k v failed to log: poisoned prefixK prefixV withK withV k v failed to log: poisoned
func NewMustContext ¶
func NewMustContext(l log.Logger, onErr func(error, ...interface{})) *MustContext
func (*MustContext) Must ¶
func (c *MustContext) Must(keyvals ...interface{})
func (*MustContext) With ¶
func (c *MustContext) With(keyvals ...interface{}) *MustContext
func (*MustContext) WithPrefix ¶
func (c *MustContext) WithPrefix(keyvals ...interface{}) *MustContext
type MustLogger ¶
MustLogger extends log.Logger with Must, an error-less version of Log.
Example ¶
mustLogger := NewMustLogger(&errLogger{}, func(err error, keyvals ...interface{}) { fmt.Println("failed to log:", err) }) mustLogger.Log("k", "v") mustLogger.Log(poison, "poison") mustLogger.Must("k", "v") mustLogger.Must(poison, "poison")
Output: k v k v failed to log: poisoned
func NewMustLogger ¶
func NewMustLogger(logger log.Logger, onErr func(error, ...interface{})) *MustLogger
func (*MustLogger) Must ¶
func (m *MustLogger) Must(keyvals ...interface{})
Click to show internal directories.
Click to hide internal directories.