diff options
Diffstat (limited to 'xmpp.go')
-rw-r--r-- | xmpp.go | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -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"` |