From b0b697cba6780b0e6182659c71dcaf6f2b220d71 Mon Sep 17 00:00:00 2001 From: Sean Lewis Date: Wed, 4 Jan 2017 14:58:36 -0700 Subject: [PATCH] flush the output buffer when it should be flushed fixes #409 --- output_file.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/output_file.go b/output_file.go index 1ac00dc..5804214 100644 --- a/output_file.go +++ b/output_file.go @@ -36,15 +36,15 @@ type FileOutputConfig struct { // FileOutput output plugin type FileOutput struct { - mu sync.Mutex - pathTemplate string - currentName string - file *os.File - queueLength int - chunkSize int - writer io.Writer - requestPerFile bool - currentID string + mu sync.Mutex + pathTemplate string + currentName string + file *os.File + queueLength int + chunkSize int + writer io.Writer + requestPerFile bool + currentID string config *FileOutputConfig } @@ -62,8 +62,9 @@ func NewFileOutput(pathTemplate string, config *FileOutputConfig) *FileOutput { go func() { for { - time.Sleep(time.Second) + time.Sleep(config.flushInterval) o.updateName() + o.flush() } }()