From 0675282097d2f43f711db8ea823ae7f0184a2506 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Wed, 10 Feb 2016 08:03:31 -0800 Subject: [PATCH] Simplified the logic of conversion of interface{} to byte array --- client/driver/syslog/collector.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/driver/syslog/collector.go b/client/driver/syslog/collector.go index e59db74a7..467add13d 100644 --- a/client/driver/syslog/collector.go +++ b/client/driver/syslog/collector.go @@ -1,6 +1,8 @@ package syslog import ( + "bytes" + "encoding/gob" "fmt" "io" "log" @@ -86,8 +88,11 @@ func (s *SyslogCollector) LaunchCollector(ctx *LogCollectorContext) (*SyslogColl go func(channel syslog.LogPartsChannel) { for logParts := range channel { - message := logParts["content"].(string) - w.Write([]byte(message)) + var buf bytes.Buffer + enc := gob.NewEncoder(&buf) + if err := enc.Encode(logParts["content"]); err == nil { + w.Write(buf.Bytes()) + } } }(channel) go s.server.Wait()