diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-09-25 20:04:01 +0200 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-09-25 20:04:01 +0200 |
commit | 0aaece7de7584f9f6ae1144ef05abc5a32d95403 (patch) | |
tree | d3085263c460837f0c06003ac260125e10228eab /lib/private/log.php | |
parent | 8f2a14c5d6956fbc6d316211d68f7d87d7349c55 (diff) | |
parent | db8e7ce8b95c882c876f932296f25ec08883a1d3 (diff) | |
download | nextcloud-server-0aaece7de7584f9f6ae1144ef05abc5a32d95403.tar.gz nextcloud-server-0aaece7de7584f9f6ae1144ef05abc5a32d95403.zip |
Merge pull request #19346 from owncloud/drop-passwords-from-exception-log
Remove passwords from logged exception stack traces
Diffstat (limited to 'lib/private/log.php')
-rw-r--r-- | lib/private/log.php | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/private/log.php b/lib/private/log.php index 3c8149bc1d0..4a0a34b7113 100644 --- a/lib/private/log.php +++ b/lib/private/log.php @@ -254,4 +254,25 @@ class Log implements ILogger { call_user_func(array($logger, 'write'), $app, $message, $level); } } + + /** + * Logs an exception very detailed + * + * @param \Exception $exception + * @param array $context + * @return void + * @since 8.2.0 + */ + public function logException(\Exception $exception, array $context = array()) { + $exception = array( + 'Exception' => get_class($exception), + 'Message' => $exception->getMessage(), + 'Code' => $exception->getCode(), + 'Trace' => $exception->getTraceAsString(), + 'File' => $exception->getFile(), + 'Line' => $exception->getLine(), + ); + $exception['Trace'] = preg_replace('!(login|checkPassword)\(.*\)!', '$1(*** username and password replaced ***)', $exception['Trace']); + $this->error('Exception: ' . json_encode($exception), $context); + } } |