Skip to content

Commit

Permalink
Merge pull request #27239 from noveens/backport-oc_jobs
Browse files Browse the repository at this point in the history
[Stable9.1] Backporting logging changes of PR #27144
  • Loading branch information
Vincent Petry authored Feb 27, 2017
2 parents aca7fdc + 4f95375 commit d61600c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 0 additions & 2 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,9 @@
break;
}

$logger->debug('Run ' . get_class($job) . ' job with ID ' . $job->getId(), ['app' => 'cron']);
$job->execute($jobList, $logger);
// clean up after unclean jobs
\OC_Util::tearDownFS();
$logger->debug('Finished ' . get_class($job) . ' job with ID ' . $job->getId(), ['app' => 'cron']);

$jobList->setLastJob($job);
$executedJobs[$job->getId()] = true;
Expand Down
11 changes: 11 additions & 0 deletions lib/private/BackgroundJob/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,18 @@ abstract class Job implements IJob {
public function execute($jobList, ILogger $logger = null) {
$jobList->setLastRun($this);
try {
//storing job start time
$jobStartTime = time();

\OCP\Util::writeLog('cron', 'Started background job of class : ' . get_class($this) . ' with arguments : ' . print_r($this->argument, true), \OCP\Util::DEBUG);

$this->run($this->argument);

//storing job end time
$jobEndTime = time();
$timeTaken = $jobEndTime - $jobStartTime;

\OCP\Util::writeLog('cron', "Finished background job, the job took : $timeTaken seconds, " . "this job is an instance of class : " . get_class($this) . 'with arguments : ' . print_r($this->argument, true), \OCP\Util::DEBUG);
} catch (\Exception $e) {
if ($logger) {
$logger->logException($e, [
Expand Down

0 comments on commit d61600c

Please sign in to comment.