Rick Reed's logging improvements

I've taken the liberty of cherry-picking @reedr's logging-related commits to clean and document them.