summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xmpp/encoder_decoder.go7
-rw-r--r--xmpp/log.go15
2 files changed, 19 insertions, 3 deletions
diff --git a/xmpp/encoder_decoder.go b/xmpp/encoder_decoder.go
index e7eeaf8..f6958be 100644
--- a/xmpp/encoder_decoder.go
+++ b/xmpp/encoder_decoder.go
@@ -5,7 +5,6 @@ import (
"errors"
"io"
"log"
- "os"
)
type encoderDecoder struct {
@@ -20,11 +19,13 @@ func newEncoderDecoder(s *session) encoderDecoder {
ed.session = s
- w := io.MultiWriter(s.transport, os.Stdout)
+ lw := logger{"TX: "}
+ w := io.MultiWriter(s.transport, lw)
ed.tx = xml.NewEncoder(w)
ed.tx.Indent("", " ")
- r := io.TeeReader(s.transport, os.Stdout)
+ lr := logger{"RX: "}
+ r := io.TeeReader(s.transport, lr)
ed.rx = xml.NewDecoder(r)
return ed
diff --git a/xmpp/log.go b/xmpp/log.go
new file mode 100644
index 0000000..4ac0f88
--- /dev/null
+++ b/xmpp/log.go
@@ -0,0 +1,15 @@
+package xmpp
+
+import (
+ "log"
+)
+
+type logger struct {
+ prefix string
+}
+
+func (l logger) Write(p []byte) (n int, err error) {
+ log.Printf("%s%s", l.prefix, string(p))
+
+ return len(p), nil
+}