Skip to content

Commit fb7a038

Browse files
committed
Fix panic when logging media name
1 parent 197ae2d commit fb7a038

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

middleware.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ func createLoggingMiddleware(logger *zap.Logger, logIPs, logUserAgent, logMediaN
155155
}
156156
}
157157

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

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

0 commit comments

Comments
 (0)