-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print sent stanzas in debug mode. #141
Conversation
Any comments on this? |
@mattn: Have you seen this PR? |
Thank you |
} else { | ||
c.p = xml.NewDecoder(c.conn) | ||
StanzaWriter = c.conn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change appears unsafe in the presence of multiple clients. All client instances will assign and write to the same package scope StanzaWriter
.
@mattn Can this be reverted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mdosch Can you handle this?
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 |
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 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 the `Client` struct and do something like this:
```go
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
}
```
|
This got reworked to also work with multiple connections as pointed out by @vcabbage in xmppo#141 (comment)
* Rework printing of sent stanzas when debug is enabled This got reworked to also work with multiple connections as pointed out by @vcabbage in #141 (comment) * Remove StanzaWriter.
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.