Simplified the logic of conversion of interface{} to byte array

This commit is contained in:
Diptanu Choudhury 2016-02-10 08:03:31 -08:00
parent 4b22221c27
commit 0675282097

View file

@ -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()