logEvent.py: move stuff into a function