tests/events.cpp: factor out the event printing into a helper function