Skip to content

Commit

Permalink
Avoid throwing away error
Browse files Browse the repository at this point in the history
Signed-off-by: Jesse Szwedko <[email protected]>
  • Loading branch information
jszwedko committed Dec 20, 2024
1 parent 3bc1ad9 commit c3f4e4e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions comp/serializer/compression/impl-gzip/gzip_strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,21 @@ func (s *GzipStrategy) NewStreamCompressor(output *bytes.Buffer) compression.Str
// Ensure level is within a range that doesn't cause NewWriterLevel to error.
level := s.level
if level < gzip.HuffmanOnly {
log.Warnf("Gzip streaming log level set to %d, minimum is %d.", level, gzip.HuffmanOnly)
log.Warnf("Gzip streaming log level set to %d, minimum is %d. Setting to minumum.", level, gzip.HuffmanOnly)
level = gzip.HuffmanOnly
}

if level > gzip.BestCompression {
log.Warnf("Gzip streaming log level set to %d, maximum is %d.", level, gzip.BestCompression)
log.Warnf("Gzip streaming log level set to %d, maximum is %d. Setting to maximum.", level, gzip.BestCompression)
level = gzip.BestCompression
}

writer, _ := gzip.NewWriterLevel(output, level)
writer, err := gzip.NewWriterLevel(output, level)
if err != nil {
log.Warnf("Error creating gzip writer with level %d. Using default.", level)
writer = gzip.NewWriter(output)
}

return writer
}

Expand Down

0 comments on commit c3f4e4e

Please sign in to comment.