X Tutup
Skip to content

Commit d61600c

Browse files
author
Vincent Petry
authored
Merge pull request #27239 from noveens/backport-oc_jobs
[Stable9.1] Backporting logging changes of PR #27144
2 parents aca7fdc + 4f95375 commit d61600c

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

cron.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,9 @@
118118
break;
119119
}
120120

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

127125
$jobList->setLastJob($job);
128126
$executedJobs[$job->getId()] = true;

lib/private/BackgroundJob/Job.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,18 @@ abstract class Job implements IJob {
4949
public function execute($jobList, ILogger $logger = null) {
5050
$jobList->setLastRun($this);
5151
try {
52+
//storing job start time
53+
$jobStartTime = time();
54+
55+
\OCP\Util::writeLog('cron', 'Started background job of class : ' . get_class($this) . ' with arguments : ' . print_r($this->argument, true), \OCP\Util::DEBUG);
56+
5257
$this->run($this->argument);
58+
59+
//storing job end time
60+
$jobEndTime = time();
61+
$timeTaken = $jobEndTime - $jobStartTime;
62+
63+
\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);
5364
} catch (\Exception $e) {
5465
if ($logger) {
5566
$logger->logException($e, [

0 commit comments

Comments
 (0)
X Tutup