Skip to content

Commit

Permalink
Access log switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
8treenet committed Jul 5, 2023
1 parent f055b8b commit a321e05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions middleware/logger_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type skipperFunc func(ctx context.Context) bool
// RequestLoggerConfig Contains the options for the logger middleware
// can be optionally be passed to the `New`.
type RequestLoggerConfig struct {
Access bool
IP bool
Query bool
MessageContextKeys []string
Expand Down Expand Up @@ -77,6 +78,7 @@ type RequestLoggerConfig struct {
// LogFunc and Skippers to nil as well.
func DefaultLoggerConfig() *RequestLoggerConfig {
return &RequestLoggerConfig{
Access: true,
IP: false,
Query: true,
RequestRawBody: true,
Expand Down
3 changes: 3 additions & 0 deletions middleware/request_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func (l *requestLoggerMiddleware) ServeHTTP(ctx context.Context) {
if !work.IsDeferRecycle() {
loggerPool.Put(freelog)
}
if !l.config.Access {
return
}

// no time.Since in order to format it well after
endTime = time.Now()
Expand Down

0 comments on commit a321e05

Please sign in to comment.