Don't create log records if we aren't going to write them.
Fixes a performance regression introduced by 14b718e31cf7c2c88bb3b38d9b7150fc57ad315c.O