summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-01-15 13:13:27 +0100
committerMorris Jobke <hey@morrisjobke.de>2016-01-20 11:06:34 +0100
commit22bba7c46ac1e3ce5f8859ebd6b23040874dd858 (patch)
tree1f903bb745cef16c368cb1727d22d1a1baa40116 /lib
parentc27dee56accf9f7d381de15d52e387999f1fb9c4 (diff)
downloadnextcloud-server-22bba7c46ac1e3ce5f8859ebd6b23040874dd858.tar.gz
nextcloud-server-22bba7c46ac1e3ce5f8859ebd6b23040874dd858.zip
Add message key to context of logException
Diffstat (limited to 'lib')
-rw-r--r--lib/private/backgroundjob/job.php6
-rw-r--r--lib/private/log.php4
-rw-r--r--lib/public/ilogger.php8
3 files changed, 15 insertions, 3 deletions
diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php
index 71ee794da50..0313895ad9f 100644
--- a/lib/private/backgroundjob/job.php
+++ b/lib/private/backgroundjob/job.php
@@ -52,8 +52,10 @@ abstract class Job implements IJob {
$this->run($this->argument);
} catch (\Exception $e) {
if ($logger) {
- $logger->error('Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')');
- $logger->logException($e);
+ $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 ee5d61e98df..fd305156766 100644
--- a/lib/private/log.php
+++ b/lib/private/log.php
@@ -273,6 +273,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 27a5d63dfdb..51d6a539900 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