mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge pull request #2699 from aynsix/PHRAS-2175-subdef-building-duration
PHRAS-2175 add subdef building duration in task log
This commit is contained in:
@@ -169,6 +169,8 @@ class SubdefGenerator
|
||||
|
||||
private function generateSubdef(\record_adapter $record, \databox_subdef $subdef_class, $pathdest)
|
||||
{
|
||||
$start = microtime(true);
|
||||
|
||||
try {
|
||||
if (null === $record->get_hd_file()) {
|
||||
$this->logger->info('No HD file found, aborting');
|
||||
@@ -203,8 +205,30 @@ class SubdefGenerator
|
||||
}
|
||||
|
||||
} catch (MediaAlchemystException $e) {
|
||||
$start = 0;
|
||||
$this->logger->error(sprintf('Subdef generation failed for record %d with message %s', $record->getRecordId(), $e->getMessage()));
|
||||
}
|
||||
|
||||
$stop = microtime(true);
|
||||
if($start){
|
||||
$duration = $stop - $start;
|
||||
|
||||
$originFileSize = $this->sizeHumanReadable($record->get_hd_file()->getSize());
|
||||
$generatedFileSize = $this->sizeHumanReadable(filesize($pathdest));
|
||||
|
||||
$this->logger->info(sprintf('*** Generated *** %s , duration=%s / source size=%s / %s size=%s / sbasid=%s / databox=%s / recordid=%s',
|
||||
$subdef_class->get_name(),
|
||||
date('H:i:s', mktime(0,0, $duration)),
|
||||
$originFileSize,
|
||||
$subdef_class->get_name(),
|
||||
$generatedFileSize,
|
||||
$record->getDatabox()->get_sbas_id(),
|
||||
$record->getDatabox()->get_dbname(),
|
||||
$record->getRecordId()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function generatePdfSubdef($source, $pathdest)
|
||||
@@ -231,4 +255,9 @@ class SubdefGenerator
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function sizeHumanReadable($bytes) {
|
||||
$i = floor(log($bytes, 1024));
|
||||
return round($bytes / pow(1024, $i), [0,0,2,2,3][$i]).['B','kB','MB','GB'][$i];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user