Skip to content

Commit

Permalink
Revert "nsq_to_file: don't open multiple GZIP streams"
Browse files Browse the repository at this point in the history
This reverts commit 5ea1012.

also some further tweaks due to FileLogger refactor
  • Loading branch information
ploxiln committed Jan 7, 2019
1 parent cf04b97 commit 6b4b720
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions apps/nsq_to_file/file_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,19 @@ func (f *FileLogger) Write(p []byte) (int, error) {
}

func (f *FileLogger) Sync() error {
var err error
if f.gzipWriter != nil {
err := f.gzipWriter.Flush()
err = f.gzipWriter.Close()
if err != nil {
return err
}
err = f.out.Sync()
f.gzipWriter, _ = gzip.NewWriterLevel(f.out, f.opts.GZIPLevel)
f.writer = f.gzipWriter
} else {
err = f.out.Sync()
}
return f.out.Sync()
return err
}

func (f *FileLogger) currentFilename() string {
Expand Down

0 comments on commit 6b4b720

Please sign in to comment.