diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2021-07-07 05:19:48 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2021-07-07 05:19:48 +0300 |
commit | 86afc1dfeeb07fbc140d08ef8cdcfd8cbd4d7bcb (patch) | |
tree | 41a2d15d113a8dba2513ca42d9c82722d1c5892b /internal/vfs/vfs.go | |
parent | e74c91bfe5c95d6da82691e0c753cc50b661613c (diff) |
Improve logging and correlation ID
Diffstat (limited to 'internal/vfs/vfs.go')
-rw-r--r-- | internal/vfs/vfs.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/internal/vfs/vfs.go b/internal/vfs/vfs.go index 2304f903..40fe8bc7 100644 --- a/internal/vfs/vfs.go +++ b/internal/vfs/vfs.go @@ -4,7 +4,8 @@ import ( "context" "strconv" - log "github.com/sirupsen/logrus" + "github.com/sirupsen/logrus" + "gitlab.com/gitlab-org/labkit/log" "gitlab.com/gitlab-org/gitlab-pages/internal/config" "gitlab.com/gitlab-org/gitlab-pages/metrics" @@ -29,15 +30,15 @@ func (i *instrumentedVFS) increment(operation string, err error) { metrics.VFSOperations.WithLabelValues(i.fs.Name(), operation, strconv.FormatBool(err == nil)).Inc() } -func (i *instrumentedVFS) log() *log.Entry { - return log.WithField("vfs", i.fs.Name()) +func (i *instrumentedVFS) log(ctx context.Context) *logrus.Entry { + return log.ContextLogger(ctx).WithField("vfs", i.fs.Name()) } func (i *instrumentedVFS) Root(ctx context.Context, path string) (Root, error) { root, err := i.fs.Root(ctx, path) i.increment("Root", err) - i.log(). + i.log(ctx). WithField("path", path). WithError(err). Traceln("Root call") |