Skip to content

Commit

Permalink
Merge pull request #375 from pacoguzman/verbose-logger-exclude-urls
Browse files Browse the repository at this point in the history
Config option to exclude URLs from verbose middleware logging
  • Loading branch information
zhouzhuojie authored Jul 13, 2020
2 parents 45be2b7 + 797d854 commit e204032
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var Config = struct {

// MiddlewareVerboseLoggerEnabled - to enable the negroni-logrus logger for all the endpoints useful for debugging
MiddlewareVerboseLoggerEnabled bool `env:"FLAGR_MIDDLEWARE_VERBOSE_LOGGER_ENABLED" envDefault:"true"`
// MiddlewareVerboseLoggerExcludeURLs - to exclude urls from the verbose logger via comma separated list
MiddlewareVerboseLoggerExcludeURLs []string `env:"FLAGR_MIDDLEWARE_VERBOSE_LOGGER_EXCLUDE_URLS" envDefault:"" envSeparator:","`
// MiddlewareGzipEnabled - to enable gzip middleware
MiddlewareGzipEnabled bool `env:"FLAGR_MIDDLEWARE_GZIP_ENABLED" envDefault:"true"`

Expand Down
8 changes: 7 additions & 1 deletion pkg/config/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ func SetupGlobalMiddleware(handler http.Handler) http.Handler {
}

if Config.MiddlewareVerboseLoggerEnabled {
n.Use(negronilogrus.NewMiddlewareFromLogger(logrus.StandardLogger(), "flagr"))
middleware := negronilogrus.NewMiddlewareFromLogger(logrus.StandardLogger(), "flagr")

for _, u := range Config.MiddlewareVerboseLoggerExcludeURLs {
middleware.ExcludeURL(u)
}

n.Use(middleware)
}

if Config.StatsdEnabled {
Expand Down

0 comments on commit e204032

Please sign in to comment.