Closed mdosch closed 1 year ago
Any comments on this?
@mattn: Have you seen this PR?
Thank you
Can you please elaborate what issues you see? I am using this for a while now and have not faced any issues.
@mdosch Are you using multiple clients concurrently? Each new client will assign to StanzaWriter
, right?
Ah, indeed I use only one connection. Unfortunately I don't have time right now to figure out an alternative implementation of printing debug output. Do you have any idea?
I think the simplest option would be to add a stanzaWriter io.Writer
field to the Client
struct and do something like this:
if o.Debug {
c.p = xml.NewDecoder(tee{c.conn, DebugWriter})
c.stanzWriter = io.MultiWriter(c.conn, DebugWriter)
} else {
c.p = xml.NewDecoder(c.conn)
c.stanzWriter = c.conn
}
Thanks, I will look into it.
Am 22. Mai 2023 14:35:24 UTC schrieb Kale Blankenship @.***>:
I think the simplest option would be to add a
stanzaWriter io.Writer
field to theClient
struct and do something like this:if o.Debug { c.p = xml.NewDecoder(tee{c.conn, DebugWriter}) c.stanzWriter = io.MultiWriter(c.conn, DebugWriter) } else { c.p = xml.NewDecoder(c.conn) c.stanzWriter = c.conn }
When debugging issues it would often be useful to also see the messages that are sent. I didn't find a way to do it as simple as you managed to do it for received stanzas but from the different approaches I tried this seems to be the best one.
I purposely didn't enable printing stanzas sent during auth to prevent people from accidentally pasting their credentials when showing logs.