diff --git a/src/logger/cmd/test_client/main.go b/src/logger/cmd/test_client/main.go index 892132a7..bc28f00b 100644 --- a/src/logger/cmd/test_client/main.go +++ b/src/logger/cmd/test_client/main.go @@ -2,23 +2,17 @@ package main import ( "bufio" - "encoding/json" + "bytes" "fmt" "os" "path/filepath" ) func log(w *bufio.Writer, event []byte, meta []byte, data []byte) { - entry, err := json.Marshal(map[string][]byte{ - "event": event, - "meta": meta, - "data": data, - }) - if err != nil { - panic(err) - } + entry := append(bytes.Join([][]byte{event, meta, data}, []byte("\t")), + byte('\n')) fmt.Printf("entry = '%s'\n", string(entry)) - _, err = w.Write(append(entry, byte('\n'))) + _, err := w.Write(entry) if err != nil { panic(err) } diff --git a/src/logger/lib.go b/src/logger/lib.go index 4a36b5e1..af7992d5 100644 --- a/src/logger/lib.go +++ b/src/logger/lib.go @@ -35,9 +35,7 @@ func NewLogger() *Logger { } type Log struct { - Event []byte `json:"event"` - Meta []byte `json:"meta"` - Data []byte `json:"data"` + Entry []byte } func (_ Log) Message() {} @@ -48,10 +46,7 @@ func (l *Logger) Receive(at time.Time, from string, event lib.InEvent) []lib.Out case *lib.InternalMessage: switch msg := (*ev).Message.(type) { case Log: - // XXX: msg.Event and msg.Meta should also be enqueued! - enqueue(l.Queue, - bytes.Join([][]byte{msg.Event, msg.Meta, msg.Data}, - []byte("\t"))) + enqueue(l.Queue, msg.Entry) default: panic(fmt.Errorf("Unknown message type: %s\n", msg)) } @@ -187,18 +182,8 @@ func NewMarshaler() *Marshaler { func (_ *Marshaler) UnmarshalMessage(message string, raw json.RawMessage, msg *lib.Message) error { switch strings.ToLower(message) { case "log": - var op struct { - Event []byte `json:"event"` - Meta []byte `json:"meta"` - Data []byte `json:"data"` - } - if err := json.Unmarshal(raw, &op); err != nil { - panic(err) - } *msg = Log{ - Event: op.Event, - Meta: op.Meta, - Data: op.Data, + Entry: raw, } default: panic(fmt.Errorf("Unknown message type: %s\n%s", message, raw)) @@ -237,7 +222,6 @@ func DeployReadOnlyPipe(pipeName string, reactor lib.Reactor, m lib.Marshaler) { // The client could prepend the line with the operation // and then add a tab to separate it from the data? if line != nil { - log.Printf("ReadBytes: '%s'\n", line) var msg lib.Message err := m.UnmarshalMessage("log", line, &msg) if err != nil {