Bpy event handler

I am working on a script to connect two blenders together with socket module, and I would need to send every action made in one blender to the other one so that it will all be synced…
I need to create a event handler that is called every time an action is made - basically every time a new line is added to the info editor report console. And then i need to filter out the ones i need to send (so that i don’t send for example menu tab change…).
How can I make that event handler?