(Bug 4876) Stop the job if it fails while setting up log file

Moves initialiaziation of $logfile out of the $log sub, so that if it
fails, and we return $temp_fail->(...), it actually cuts the import
short.

Otherwise, the import job just continues, just with no logging, and the
user gets both a "succeeded" and "failed" message in their inbox.
Confusing!
(Bug 4876) Fix timestamp when logfile is first opened
Merge pull request #262 from afuna/fail-log-bug4876

(Bug 4876) Stop the job if it fails while setting up log file