diff --git a/api/app/account.go b/api/app/account.go index b98c7fe..b16b0f3 100644 --- a/api/app/account.go +++ b/api/app/account.go @@ -11,7 +11,6 @@ import ( validation "github.com/go-ozzo/ozzo-validation" "github.com/dhax/go-base/auth" - "github.com/dhax/go-base/logging" "github.com/dhax/go-base/models" ) @@ -54,11 +53,11 @@ func (rs *AccountResource) router() *chi.Mux { func (rs *AccountResource) accountCtx(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { claims := auth.ClaimsFromCtx(r.Context()) - logging.GetLogEntry(r).WithField("account_id", claims.ID) + log(r).WithField("account_id", claims.ID) account, err := rs.Store.Get(claims.ID) if err != nil { // account deleted while access token still valid - logging.GetLogEntry(r).WithField("account", claims.Sub).Warn(err) + log(r).WithField("account", claims.Sub).Warn(err) render.Render(w, r, ErrNotFound) return } diff --git a/api/app/api.go b/api/app/api.go index 7bbf6bd..60a9487 100644 --- a/api/app/api.go +++ b/api/app/api.go @@ -1,10 +1,14 @@ package app import ( + "net/http" + "github.com/go-chi/chi" "github.com/go-pg/pg" + "github.com/sirupsen/logrus" "github.com/dhax/go-base/database" + "github.com/dhax/go-base/logging" ) type ctxKey int @@ -37,3 +41,7 @@ func (a *API) Router() *chi.Mux { return r } + +func log(r *http.Request) logrus.FieldLogger { + return logging.GetLogEntry(r) +}