Clean up the logging system (part 1 of 2).

The second part of this will be slightly more tweaky. I'm filing this part now to avoid a ton of merge conflicts later as i'm not sure when the second part will be done.