Skip to content

Commit

Permalink
Merge pull request #43 from brave/env_request_logs
Browse files Browse the repository at this point in the history
Fix 42: Request logging is gated behind an environment variable
  • Loading branch information
jumde authored Apr 21, 2020
2 parents c8f5d13 + ef912d9 commit 6b31574
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/sirupsen/logrus"
"log"
"net/http"
"os"
"time"
)

Expand All @@ -33,7 +34,8 @@ func setupRouter(ctx context.Context, logger *logrus.Logger, testRouter bool) (c
r.Use(chiware.Heartbeat("/"))
r.Use(chiware.Timeout(60 * time.Second))
r.Use(middleware.BearerToken)
if logger != nil {
log, ok := os.LookupEnv("LOG_REQUEST")
if ok && log == "true" && logger != nil {
// Also handles panic recovery
r.Use(middleware.RequestLogger(logger))
}
Expand Down

0 comments on commit 6b31574

Please sign in to comment.