Added debug info to the export routine.

This commit is contained in:
James Cole
2016-02-23 06:39:01 +01:00
parent 28fd719ce3
commit deeeb06488
8 changed files with 62 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\ExportJob;
use FireflyIII\Models\TransactionJournal;
use Illuminate\Support\Collection;
use Log;
use ZipArchive;
/**
@@ -88,6 +89,13 @@ class Processor
$args = [$this->accounts, Auth::user(), $this->settings['startDate'], $this->settings['endDate']];
$journalCollector = app('FireflyIII\Export\JournalCollector', $args);
$this->journals = $journalCollector->collect();
Log::debug(
'Collected ' .
$this->journals->count() . ' journals (between ' .
$this->settings['startDate']->format('Y-m-d') . ' and ' .
$this->settings['endDate']->format('Y-m-d')
. ').'
);
}
public function collectOldUploads()
@@ -103,10 +111,13 @@ class Processor
*/
public function convertJournals()
{
$count = 0;
/** @var TransactionJournal $journal */
foreach ($this->journals as $journal) {
$this->exportEntries->push(Entry::fromJournal($journal));
$count++;
}
Log::debug('Converted ' . $count . ' journals to "Entry" objects.');
}
public function createConfigFile()
@@ -119,6 +130,7 @@ class Processor
{
$zip = new ZipArchive;
$filename = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '.zip';
Log::debug('Will create zip file at ' . $filename);
if ($zip->open($filename, ZipArchive::CREATE) !== true) {
throw new FireflyException('Cannot store zip file.');
@@ -127,6 +139,7 @@ class Processor
$search = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-';
/** @var string $file */
foreach ($this->getFiles() as $file) {
Log::debug('Will add "' . $file . '" to zip file.');
$zipName = str_replace($search, '', $file);
$zip->addFile($file, $zipName);
}
@@ -134,8 +147,10 @@ class Processor
// delete the files:
foreach ($this->getFiles() as $file) {
Log::debug('Will now delete file "' . $file . '".');
unlink($file);
}
Log::debug('Done!');
}
/**
@@ -145,9 +160,11 @@ class Processor
{
$exporterClass = Config::get('firefly.export_formats.' . $this->exportFormat);
$exporter = app($exporterClass, [$this->job]);
Log::debug('Going to export ' . $this->exportEntries->count() . ' export entries into ' . $this->exportFormat . ' format.');
$exporter->setEntries($this->exportEntries);
$exporter->run();
$this->files->push($exporter->getFileName());
Log::debug('Added "' . $exporter->getFileName() . '" to the list of files to include in the zip.');
}
/**