From 2662bcd350c51ee3a0db2a7750fe4551de23fb04 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 10 May 2023 21:47:02 +0200 Subject: Implement pretty-printed server side XML logging --- xmpp.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'xmpp.go') diff --git a/xmpp.go b/xmpp.go index 6f24c86..6540ae5 100644 --- a/xmpp.go +++ b/xmpp.go @@ -1,7 +1,6 @@ package main import ( - "io" "os" "crypto/tls" "crypto/x509" @@ -34,15 +33,13 @@ func (l *Limox) xmpp(jid string, pwd string) { return } - multiw := io.MultiWriter(conn, os.Stdout) - enc := xml.NewEncoder(multiw) + enc := xml.NewEncoder(conn) receiver := make(chan xml.Token) termination := make(chan bool) go func() { quit := false - tee := io.TeeReader(conn, os.Stdout) - dec := xml.NewDecoder(tee) + dec := xml.NewDecoder(conn) for { select { case <-termination: @@ -60,6 +57,8 @@ func (l *Limox) xmpp(jid string, pwd string) { log.Println("Done!") }() + dbg := xml.NewEncoder(os.Stdout) + end := sendStreamStart(enc, jid) l.XmppEvents <- XmppConnect @@ -72,10 +71,12 @@ func (l *Limox) xmpp(jid string, pwd string) { termination <- true closing = true default: - //log.Fatalf("Unknown GuiEvent '%d'!\n", ev) + log.Fatalf("Unknown GuiEvent '%d'!\n", ev) } - case <-receiver: - // ignoring incoming XML tokens for now ... + case rx := <-receiver: + dbg.Indent("S: ", " ") + dbg.EncodeToken(rx) + dbg.Flush() } if closing { -- cgit v1.2.3-70-g09d2