Clean up log entry writing code a bit