summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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"`