Skip to content

Commit

Permalink
Merge pull request #128 from Dash-Industry-Forum/fix-logging
Browse files Browse the repository at this point in the history
fix: status code and bytecount in request log
  • Loading branch information
tobbee authored Oct 29, 2023
2 parents 032e687 + 0b4e07d commit e5ac331
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 2 additions & 5 deletions cmd/livesim2/app/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ func SetupServer(ctx context.Context, cfg *ServerConfig) (*Server, error) {
r.Use(middleware.Recoverer)
r.Use(addVersionAndCORSHeaders)
prometheusMiddleWare := NewPrometheusMiddleware()

l := chi.NewRouter()
r.Use(prometheusMiddleWare)

v := chi.NewRouter()
r.Use(prometheusMiddleWare)

// Set a timeout value on the request context (ctx), that will signal
Expand All @@ -49,6 +44,8 @@ func SetupServer(ctx context.Context, cfg *ServerConfig) (*Server, error) {
r.Mount("/metrics", promhttp.Handler())

var reqLimiter *IPRequestLimiter
l := chi.NewRouter()
v := chi.NewRouter()
if cfg.MaxRequests > 0 {
reqLimiter = NewIPRequestLimiter(cfg.MaxRequests, time.Duration(cfg.ReqLimitInt)*time.Second, time.Now(), cfg.ReqLimitLog)
ltrMw := NewLimiterMiddleware("Livesim2-Requests", reqLimiter)
Expand Down
2 changes: 1 addition & 1 deletion pkg/logging/slog.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ func SlogMiddleWare(l *slog.Logger) func(next http.Handler) http.Handler {
l2 = l2.With("bytes_in", bytesIn)
}
l2.Info("request")
next.ServeHTTP(ww, r)
}()
next.ServeHTTP(ww, r)
}
return http.HandlerFunc(fn)
}
Expand Down

0 comments on commit e5ac331

Please sign in to comment.