Publish events for tracking logs

This time, this is a single pull request, as my workflow wasn't as clean as usual.

Also, there is plenty of repetition, but I see no clean way to factor it out.
Ok.