pypubsub icon indicating copy to clipboard operation
pypubsub copied to clipboard

How to view Handled messages

Open paddymccrudden opened this issue 5 years ago • 3 comments
trafficstars

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

paddymccrudden avatar Jan 07 '20 22:01 paddymccrudden

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.

schollii avatar Jul 10 '20 14:07 schollii

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?

paddymccrudden avatar Jul 12 '20 02:07 paddymccrudden

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.

schollii avatar Jul 12 '20 13:07 schollii