diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-15 20:12:26 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-01-15 20:12:26 +0100 |
commit | 807cf750b3f26da3c9e504ad9d5ce165dd4f6e32 (patch) | |
tree | e1f676b2ced0b8bbcd071839c638f21675eecbdc /lib | |
parent | fcec704174a384f93214a1f2b83bed385e763ff6 (diff) | |
parent | f6c4b10189c6d76d94b0b01a440a326e6346c301 (diff) | |
download | nextcloud-server-807cf750b3f26da3c9e504ad9d5ce165dd4f6e32.tar.gz nextcloud-server-807cf750b3f26da3c9e504ad9d5ce165dd4f6e32.zip |
Merge pull request #21705 from owncloud/improve-background-job-message
Improve background job error message
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/backgroundjob/job.php | 5 | ||||
-rw-r--r-- | lib/private/log.php | 4 | ||||
-rw-r--r-- | lib/public/ilogger.php | 8 |
3 files changed, 15 insertions, 2 deletions
diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php index 677b37e9297..e7268894848 100644 --- a/lib/private/backgroundjob/job.php +++ b/lib/private/backgroundjob/job.php @@ -52,7 +52,10 @@ abstract class Job implements IJob { $this->run($this->argument); } catch (\Exception $e) { if ($logger) { - $logger->error('Error while running background job: ' . $e->getMessage()); + $logger->logException($e, [ + 'app' => 'core', + 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')' + ]); } } } diff --git a/lib/private/log.php b/lib/private/log.php index 6c1666a9d7f..addefe6e53d 100644 --- a/lib/private/log.php +++ b/lib/private/log.php @@ -285,6 +285,8 @@ class Log implements ILogger { 'Line' => $exception->getLine(), ); $exception['Trace'] = preg_replace('!(login|checkPassword)\(.*\)!', '$1(*** username and password replaced ***)', $exception['Trace']); - $this->error('Exception: ' . json_encode($exception), $context); + $msg = isset($context['message']) ? $context['message'] : 'Exception'; + $msg .= ': ' . json_encode($exception); + $this->error($msg, $context); } } diff --git a/lib/public/ilogger.php b/lib/public/ilogger.php index 368b25ab693..2a727697a6a 100644 --- a/lib/public/ilogger.php +++ b/lib/public/ilogger.php @@ -125,6 +125,14 @@ interface ILogger { /** * Logs an exception very detailed + * An additional message can we written to the log by adding it to the + * context. + * + * <code> + * $logger->logException($ex, [ + * 'message' => 'Exception during cron job execution' + * ]); + * </code> * * @param \Exception $exception * @param array $context |