From c3d0fa7d8c2395a95f59a4678538645e8de2669c Mon Sep 17 00:00:00 2001 From: Andrew Kroh Date: Wed, 6 Jan 2016 13:37:17 -0500 Subject: [PATCH] Join the logging of the message and the newline into one Write Fixes #646 --- CHANGELOG.asciidoc | 2 ++ libbeat/logp/file_rotator.go | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index d8f90211197..8f4f4c51c78 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -26,6 +26,8 @@ https://github.com/elastic/beats/compare/1.0.0...master[Check the HEAD diff] ==== Bugfixes *Affecting all Beats* +- Fix logging issue with file based output where newlines could be misplaced + during concurrent logging {pull}650[650] *Packetbeat* - Fix setting direction to out and use its value to decide when dropping events if ignore_outgoing is enabled {pull}557[557] diff --git a/libbeat/logp/file_rotator.go b/libbeat/logp/file_rotator.go index af8906384b1..8e34fe3d6b5 100644 --- a/libbeat/logp/file_rotator.go +++ b/libbeat/logp/file_rotator.go @@ -66,15 +66,13 @@ func (rotator *FileRotator) WriteLine(line []byte) error { return err } } + + line = append(line, '\n') _, err := rotator.current.Write(line) if err != nil { return err } - _, err = rotator.current.Write([]byte("\n")) - if err != nil { - return err - } - rotator.current_size += uint64(len(line) + 1) + rotator.current_size += uint64(len(line)) return nil }