Skip to content

Commit

Permalink
Use logger for request context, incl. request id
Browse files Browse the repository at this point in the history
  • Loading branch information
irees committed Dec 12, 2024
1 parent b554b2a commit 98ba430
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
4 changes: 3 additions & 1 deletion cmd/tlserver/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,9 @@ func (cmd *ServerCommand) Run() error {
root.Use(usercheck.AdminDefaultMiddleware("admin"))

// Add logging middleware - must be after auth
root.Use(log.LoggingMiddleware(cmd.LongQueryDuration, func(ctx context.Context) string {
root.Use(log.RequestIDMiddleware)
root.Use(log.RequestIDLoggingMiddleware)
root.Use(log.DurationLoggingMiddleware(cmd.LongQueryDuration, func(ctx context.Context) string {
if user := authn.ForContext(ctx); user != nil {
return user.Name()
}
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ require (
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
github.com/graph-gophers/dataloader/v7 v7.1.0
github.com/hypirion/go-filecache v0.0.0-20160810125507-e3e6ef6981f0
github.com/interline-io/log v0.0.0-20240613202707-4e3adcc06d2d
github.com/interline-io/transitland-dbutil v0.0.0-20241211003846-754ca2a37d9d
github.com/interline-io/transitland-jobs v0.0.0-20241211004034-cf0f5587b01d
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241212015927-9ee6e945325d
github.com/interline-io/transitland-mw v0.0.0-20241211003943-b546af52d409
github.com/interline-io/log v0.0.0-20241212203449-4bcff214cd71
github.com/interline-io/transitland-dbutil v0.0.0-20241212203507-15a69a52c1c4
github.com/interline-io/transitland-jobs v0.0.0-20241212203627-25dc585dcf7e
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241212203529-97599f3e6ac2
github.com/interline-io/transitland-mw v0.0.0-20241212203557-2e0c0fea3d26
github.com/jmoiron/sqlx v1.4.0
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6
github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/interline-io/log v0.0.0-20240613202707-4e3adcc06d2d h1:XToGkREjPhy6Ha6yUfKP7P4O2vRKc4xNGUFeo8nshjA=
github.com/interline-io/log v0.0.0-20240613202707-4e3adcc06d2d/go.mod h1:chJaM8SKcHI6ivoeFuZ8M8axTjSV4TPmuQ+sAyAHa34=
github.com/interline-io/transitland-dbutil v0.0.0-20241211003846-754ca2a37d9d h1:W9IWIKh6R+m5ueRol8J0mnw3WtuUnxU0J+2qlu+Dd0k=
github.com/interline-io/transitland-dbutil v0.0.0-20241211003846-754ca2a37d9d/go.mod h1:gcuaCPdtpzopTWKJyRWMDTDFQ59bvX0OUWSccoLCcoQ=
github.com/interline-io/transitland-jobs v0.0.0-20241211004034-cf0f5587b01d h1:OovUOl7eM8qrukLwkx+WTSaFz2FaExIGYDlmSZ6iWeo=
github.com/interline-io/transitland-jobs v0.0.0-20241211004034-cf0f5587b01d/go.mod h1:lR+WSE0BqU2notk69Ei0WR+WHUpUHWraIhcQgIh10+A=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241212015927-9ee6e945325d h1:5WA97lN4pEj/umJZZUUv4XeMvnt8rpOz54CWas11S0c=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241212015927-9ee6e945325d/go.mod h1:x8NJexNljTnw12YWtUUiVmQIrMQFurs8lIkR6VzHUeI=
github.com/interline-io/transitland-mw v0.0.0-20241211003943-b546af52d409 h1:pQV47Wwmw6zQZvzGKlIVgqkgmKe99js0h03kLonN+g8=
github.com/interline-io/transitland-mw v0.0.0-20241211003943-b546af52d409/go.mod h1:yS3MZZfO3w6cR28KMMcrHBcLGM2sWem5IQicdKbw4zw=
github.com/interline-io/log v0.0.0-20241212203449-4bcff214cd71 h1:RI4mfj5B0VPK3XznLKTRPzFScySmRDYYp6tACSqZfoE=
github.com/interline-io/log v0.0.0-20241212203449-4bcff214cd71/go.mod h1:chJaM8SKcHI6ivoeFuZ8M8axTjSV4TPmuQ+sAyAHa34=
github.com/interline-io/transitland-dbutil v0.0.0-20241212203507-15a69a52c1c4 h1:25yHjhbhKqJI5Gt/16WVQ2m9HtsymVm46UdAm50i/wg=
github.com/interline-io/transitland-dbutil v0.0.0-20241212203507-15a69a52c1c4/go.mod h1:aPEEJCvUPJoxyzA6sP4/PF4thA+hpafYpUcFBgoKK50=
github.com/interline-io/transitland-jobs v0.0.0-20241212203627-25dc585dcf7e h1:1yYXM017Sm6qAPqwKT+SQ+WBbpGpVSGqyNbtcPHS+EU=
github.com/interline-io/transitland-jobs v0.0.0-20241212203627-25dc585dcf7e/go.mod h1:+lu9T9vafIPrucNWn21+UIrmd3MYeAbV3bEWkpT5Oxo=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241212203529-97599f3e6ac2 h1:c/1LraxxyIWE+gY53hhZY8zn87MgxMoX2RKjCp+CJq8=
github.com/interline-io/transitland-lib v1.0.0-rc3.0.20241212203529-97599f3e6ac2/go.mod h1:RBqVLgH11BpAv4KU+hllViwAjtcRUEAJ3tTWxXaNuJU=
github.com/interline-io/transitland-mw v0.0.0-20241212203557-2e0c0fea3d26 h1:YNFsJU00rvfQyoTbKmgIAZJscdEZYn75rTR2d4aHfFs=
github.com/interline-io/transitland-mw v0.0.0-20241212203557-2e0c0fea3d26/go.mod h1:zPjgFce6JY8gHrm35Jdp59PKSQrpNfUSHN8B5I8cXSU=
github.com/invopop/yaml v0.3.1 h1:f0+ZpmhfBSS4MhG+4HYseMdJhoeeopbSKbq5Rpeelso=
github.com/invopop/yaml v0.3.1/go.mod h1:PMOp3nn4/12yEZUFfmOuNHJsZToEEOwoWsT+D81KkeA=
github.com/irees/kin-openapi v0.0.0-20240827112008-5f0d6c653b17 h1:8r3a8+gGbNCrB+sF5BhzOUU5N7vo7vbwz1MGmYoq5TI=
Expand Down

0 comments on commit 98ba430

Please sign in to comment.