Fixed files and diff leaking.

I fixed a shameful bug in my code that was leaking temp files and
dropping some diffs. I also introduced some form of structured logging
as well.

Change-Id: I3d09b78365615e66add96fff33190a36b9498af4
Signed-off-by: Giuseppe Lavagetto <glavagetto@wikimedia.org>