Skip to content

jmank88/mustlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MustLog GoDoc Go Report Card

An error-less go-kit/log extension.

MustLogger

MustLogger extends log.Logger with Must, an error-less version of Log.

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

MustContext

MustContext extends log.Context to implement MustLogger.

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

About

error-less go-kit/log extension

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages