Skip to content

Simple wrapper for using logrus with context.Context

License

Notifications You must be signed in to change notification settings

imax9000/ctxlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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"
    // ...

About

Simple wrapper for using logrus with context.Context

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages