apex / log

Structured logging package for Go.
MIT License
1.36k stars 110 forks source link

Allow Trace.Stop(*error) to be called multiple times and only log once #77

Closed matthewmueller closed 4 years ago

matthewmueller commented 4 years ago

If you have:

func (a *API) Check(w http.ResponseWriter, r *http.Request) {
  log := a.log.Trace("check")
  defer log.Stop(nil)
  if err := check(); err != nil {
    log.Stop(&err)
    return
  }
}

If there's an error, you'll have two log entries for stopping the trace. It'd be great do only log once for the first one.

tj commented 4 years ago

Need to think about tracing some more, it might be nice to do a 2.0 that is more like opentracing or something already established

matthewmueller commented 4 years ago

Agreed!

wesleimp commented 4 years ago

@tj can we close this issue?

matthewmueller commented 4 years ago

I don't think this is solved, but I also haven't run into it since Dec 2019 haha.