pypubsub
pypubsub copied to clipboard
How to view Handled messages
Hi,
I am in the process of debugging and application that uses PyPubSub for its messages. I am using the snoop methods (https://pypubsub.readthedocs.io/en/v4.0.3/usage/usage_advanced_debug.html#id4) to see which messages are published. However, I'd really like to also log whenever a handler receives a message. Is there a means of doing so easily?
Paddy
Have you looked at the notification handlers? They will notify on various pubsub related activities like message publish, message received by which listener, topic created/deleted, etc.
Thanks - I ended up enforcing some structure on my listeners to log the events. It worked well. I did this as I couldn't see how the notification handlers managed listeners. Do you have a link on that?
Yes have a look at
- https://github.com/schollii/pypubsub/blob/master/examples/advanced/notifhandle.py
- https://pypubsub.readthedocs.io/en/v4.0.3/usage/module_utils.html#pubsub.utils.IgnoreNotificationsMixin
The notifySend() method of your custom handler gets called several times for each listener.