Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Stable9.1] Backporting logging changes of PR #27144 #27239

Merged
merged 2 commits into from
Feb 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the ); up or split the line better.


$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
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the ); up or split the line better.

} catch (\Exception $e) {
if ($logger) {
$logger->logException($e, [
Expand Down