Skip to content

Commit

Permalink
backporting logging changes of PR owncloud#27144
Browse files Browse the repository at this point in the history
  • Loading branch information
noveens committed Feb 23, 2017
1 parent ed0ce60 commit 75df4ea
Show file tree
Hide file tree
Showing 2 changed files with 13 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
13 changes: 13 additions & 0 deletions lib/private/BackgroundJob/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,20 @@ 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 75df4ea

Please sign in to comment.