Build log write error checking.

Like f6f00aa40f0c541df06, but for the build log instead of the deps log.
Merge pull request #626 from nico/logwrite

Build log write error checking.