Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 646 Bytes

README.md

File metadata and controls

20 lines (15 loc) · 646 Bytes

Wrappers for using logrus with context.Context

GoDoc

Example usage:

ctx = ctxlog.WithField(ctx, "user", user)
// ...
ctxlog.With(ctx).Printf("User did something")  // resulting entry will have field "user"

You can also use it to trace request handling across function boundaries:

func handleHTTP(w http.ResponseWriter, r *http.Request) {
    ctx := ctxlog.WithField(context.Background(), "request_id", genRequestID())
    doStuff(ctx)  // if doStuff uses ctxlog too, all entries will have "request_id"
    // ...