aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/BackgroundJob/Job.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/BackgroundJob/Job.php')
-rw-r--r--lib/private/BackgroundJob/Job.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/private/BackgroundJob/Job.php b/lib/private/BackgroundJob/Job.php
index 726c66ef5d7..cb9328f01b9 100644
--- a/lib/private/BackgroundJob/Job.php
+++ b/lib/private/BackgroundJob/Job.php
@@ -49,8 +49,18 @@ abstract class Job implements IJob {
*/
public function execute($jobList, ILogger $logger = null) {
$jobList->setLastRun($this);
+ if ($logger === null) {
+ $logger = \OC::$server->getLogger();
+ }
+
try {
+ $jobStartTime = time();
+ $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']);
$this->run($this->argument);
+ $timeTaken = time() - $jobStartTime;
+
+ $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']);
+ $jobList->setExecutionTime($this, $timeTaken);
} catch (\Exception $e) {
if ($logger) {
$logger->logException($e, [