summaryrefslogtreecommitdiff
path: root/xmpp.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-05-09 20:53:22 +0200
committerxengineering <me@xengineering.eu>2023-05-09 20:53:22 +0200
commita812aabfe1d96fbdaf5a40dd8fb6654d943a8380 (patch)
treebb0bcd59ddeac98e2953fdb568b277257bcafb1d /xmpp.go
parent8ab83cfe65a5487f62ca6d1d2c612a7505c6bd70 (diff)
downloadlimox-a812aabfe1d96fbdaf5a40dd8fb6654d943a8380.tar
limox-a812aabfe1d96fbdaf5a40dd8fb6654d943a8380.tar.zst
limox-a812aabfe1d96fbdaf5a40dd8fb6654d943a8380.zip
Implement logToken()
This is a generic XML token logging function which can be used for sent and received XML tokens.
Diffstat (limited to 'xmpp.go')
-rw-r--r--xmpp.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/xmpp.go b/xmpp.go
index a8dbcee..36d2135 100644
--- a/xmpp.go
+++ b/xmpp.go
@@ -77,12 +77,7 @@ func (l *Limox) xmpp(jid string, pwd string) {
//log.Fatalf("Unknown GuiEvent '%d'!\n", ev)
}
case rx := <-receiver:
- switch rx.(type) {
- case xml.CharData:
- log.Printf("S: [ %v ] %s\n", reflect.TypeOf(rx), rx)
- default:
- log.Printf("S: [ %v ] %+v\n", reflect.TypeOf(rx), rx)
- }
+ logToken(rx, false)
}
if closing {
@@ -95,6 +90,22 @@ func (l *Limox) xmpp(jid string, pwd string) {
l.XmppEvents <- XmppDisconnect
}
+func logToken(t xml.Token, isTx bool) {
+ 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)
+ }
+}
+
type StreamInit struct {
XMLName xml.Name `xml:"stream:stream"`
From string `xml:"from,attr"`