neilotoole.io

Web presence of Neil O'Toole.

lg v0.2

The first version of the lg package, released years ago, was one of those rites of passage for Go devs: everybody needs to do their own logger implementation at least once. This v0.2 release has a legitimate purpose: it is an exploration of a small, leveled, unstructured logging interface for enterprise applications. lg delegates the actual log entry creation to backing libs (such as uber/zap), explores some idioms (log.WarnIfFuncError), and plays nicely with testing.T.

Example:

func DoSomething(log lg.Log) error {
  f, err := os.Open("filename")
  if err != nil {
    return err
  }
  defer log.WarnIfFuncError(f.Close)

See the repo for more.