summaryrefslogtreecommitdiff
path: root/xmpp.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-05-10 18:13:30 +0200
committerxengineering <me@xengineering.eu>2023-05-10 18:22:31 +0200
commitbe69cea228f4674862b8c25f11f044f82dbc13bb (patch)
tree7fc22cd14621f64b1eba7d08652c1961d31d6d66 /xmpp.go
parentf82aa566910de95288311076d15ebc9c4b0d279a (diff)
downloadlimox-be69cea228f4674862b8c25f11f044f82dbc13bb.tar
limox-be69cea228f4674862b8c25f11f044f82dbc13bb.tar.zst
limox-be69cea228f4674862b8c25f11f044f82dbc13bb.zip
Replace XML token logging completely
Using io.TeeReader and io.MultiWriter is a better debugging interface since it is exactly what is transmitted via the TCP connection.
Diffstat (limited to 'xmpp.go')
-rw-r--r--xmpp.go24
1 files changed, 2 insertions, 22 deletions
diff --git a/xmpp.go b/xmpp.go
index c9ae054..6f24c86 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -7,7 +7,6 @@ import (
"crypto/x509"
"encoding/xml"
"log"
- "reflect"
)
type XmppEvent uint8
@@ -35,7 +34,8 @@ func (l *Limox) xmpp(jid string, pwd string) {
return
}
- enc := xml.NewEncoder(conn)
+ multiw := io.MultiWriter(conn, os.Stdout)
+ enc := xml.NewEncoder(multiw)
receiver := make(chan xml.Token)
termination := make(chan bool)
@@ -88,23 +88,6 @@ func (l *Limox) xmpp(jid string, pwd string) {
l.XmppEvents <- XmppDisconnect
}
-func logToken(t xml.Token, isTx bool) {
- return
- var prefix string
- if isTx {
- prefix = "C"
- } else {
- prefix = "S"
- }
-
- switch t.(type) {
- case xml.CharData:
- log.Printf("%s: [ %v ] %s\n", prefix, reflect.TypeOf(t), t)
- default:
- log.Printf("%s: [ %v ] %+v\n", prefix, reflect.TypeOf(t), t)
- }
-}
-
func sendStreamStart(enc *xml.Encoder, jid string) (xml.EndElement) {
start := xml.StartElement{
xml.Name{"jabber:client", "stream:stream"},
@@ -127,7 +110,6 @@ func sendStreamStart(enc *xml.Encoder, jid string) (xml.EndElement) {
log.Fatal("Could not flush XML encoder!")
}
- logToken(start, true)
return start.End()
}
@@ -141,8 +123,6 @@ func sendStreamEnd(enc *xml.Encoder, end xml.EndElement) {
if err != nil {
log.Fatal("Could not flush XML encoder!")
}
-
- logToken(end, true)
}
// domainpart extracts the domain name from a JID / XMPP address. See