Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 124fe87

Browse files
committed
Use the accessor, duh.
1 parent 4c60c39 commit 124fe87

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

plugins/file/file_output.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,7 @@ func (o *FileOutput) handleMessage(pack *PipelinePack, outBytes *[]byte) (err er
267267
err = fmt.Errorf("Can't encode to JSON: %s", err)
268268
}
269269
case "text":
270-
if pack.Message.Payload == nil {
271-
*outBytes = append(*outBytes, []byte("<NIL>")...)
272-
} else {
273-
*outBytes = append(*outBytes, *pack.Message.Payload...)
274-
}
270+
*outBytes = append(*outBytes, pack.Message.GetPayload()...)
275271
*outBytes = append(*outBytes, NEWLINE)
276272
case "protobufstream":
277273
if err = ProtobufEncodeMessage(pack, &*outBytes); err != nil {

plugins/file/file_output_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func FileOutputSpec(c gs.Context) {
9292
err = fileOutput.handleMessage(pack, &outData)
9393
c.Expect(err, gs.IsNil)
9494
strContents := toString(&outData)
95-
c.Expect(strContents, gs.Equals, "<NIL>\n")
95+
c.Expect(strContents, gs.Equals, "\n")
9696
})
9797

9898
c.Specify("payload is nil and with a timestamp", func() {
@@ -105,7 +105,7 @@ func FileOutputSpec(c gs.Context) {
105105
todayStr := time.Now().Format("[2006/Jan/02:")
106106
strContents := toString(&outData)
107107
c.Expect(strings.HasPrefix(strContents, todayStr), gs.IsTrue)
108-
c.Expect(strings.HasSuffix(strContents, "<NIL>\n"), gs.IsTrue)
108+
c.Expect(strings.HasSuffix(strContents, " \n"), gs.IsTrue)
109109
})
110110
})
111111

0 commit comments

Comments
 (0)