Skip to content

Commit

Permalink
Fix panic when logging media name
Browse files Browse the repository at this point in the history
  • Loading branch information
doingodswork committed Aug 27, 2020
1 parent 197ae2d commit fb7a038
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions middleware.go
Expand Up @@ -155,11 +155,13 @@ func createLoggingMiddleware(logger *zap.Logger, logIPs, logUserAgent, logMediaN
}
}

var zapFields []zap.Field
// TODO: To increase performance, don't create a new slice for every request. Use sync.Pool.
if logMediaName && isStream {
zapFieldCount++
zapFields = make([]zap.Field, zapFieldCount+1)
} else {
zapFields = make([]zap.Field, zapFieldCount)
}
// TODO: To increase performance, don't create a new slice for every request. Use sync.Pool.
zapFields := make([]zap.Field, zapFieldCount)

duration := time.Since(start).Milliseconds()
durationString := strconv.FormatInt(duration, 10) + "ms"
Expand Down

0 comments on commit fb7a038

Please sign in to comment.