aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Log
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/Log')
-rw-r--r--lib/private/Log/ErrorHandler.php23
-rw-r--r--lib/private/Log/ExceptionSerializer.php3
-rw-r--r--lib/private/Log/File.php1
-rw-r--r--lib/private/Log/LogDetails.php17
-rw-r--r--lib/private/Log/LogFactory.php3
-rw-r--r--lib/private/Log/PsrLoggerAdapter.php3
-rw-r--r--lib/private/Log/Rotate.php2
-rw-r--r--lib/private/Log/Syslog.php2
-rw-r--r--lib/private/Log/Systemdlog.php3
9 files changed, 34 insertions, 23 deletions
diff --git a/lib/private/Log/ErrorHandler.php b/lib/private/Log/ErrorHandler.php
index 5c84c61e744..6c969fa093c 100644
--- a/lib/private/Log/ErrorHandler.php
+++ b/lib/private/Log/ErrorHandler.php
@@ -5,6 +5,7 @@
* @author Bart Visscher <bartv@thisnet.nl>
* @author Björn Schießle <bjoern@schiessle.org>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
+ * @author Joas Schilling <coding@schilljs.com>
* @author Julius Härtl <jus@bitgrid.net>
* @author Morris Jobke <hey@morrisjobke.de>
* @author Thomas Müller <thomas.mueller@tmit.eu>
@@ -24,7 +25,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
namespace OC\Log;
use OCP\ILogger;
@@ -90,13 +90,30 @@ class ErrorHandler {
}
$msg = $message . ' at ' . $file . '#' . $line;
$e = new \Error(self::removePassword($msg));
- self::$logger->logException($e, ['app' => 'PHP']);
+ self::$logger->logException($e, ['app' => 'PHP', 'level' => self::errnoToLogLevel($number)]);
}
//Recoverable handler which catch all errors, warnings and notices
public static function onAll($number, $message, $file, $line) {
$msg = $message . ' at ' . $file . '#' . $line;
$e = new \Error(self::removePassword($msg));
- self::$logger->logException($e, ['app' => 'PHP', 'level' => 0]);
+ self::$logger->logException($e, ['app' => 'PHP', 'level' => self::errnoToLogLevel($number)]);
+ }
+
+ public static function errnoToLogLevel(int $errno): int {
+ switch ($errno) {
+ case E_USER_WARNING:
+ return ILogger::WARN;
+
+ case E_USER_DEPRECATED:
+ return ILogger::DEBUG;
+
+ case E_USER_NOTICE:
+ return ILogger::INFO;
+
+ case E_USER_ERROR:
+ default:
+ return ILogger::ERROR;
+ }
}
}
diff --git a/lib/private/Log/ExceptionSerializer.php b/lib/private/Log/ExceptionSerializer.php
index b62293946d0..aba5586297a 100644
--- a/lib/private/Log/ExceptionSerializer.php
+++ b/lib/private/Log/ExceptionSerializer.php
@@ -19,14 +19,13 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
namespace OC\Log;
use OC\Core\Controller\SetupController;
diff --git a/lib/private/Log/File.php b/lib/private/Log/File.php
index afeab1b8fd7..a33667c9b68 100644
--- a/lib/private/Log/File.php
+++ b/lib/private/Log/File.php
@@ -34,7 +34,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
namespace OC\Log;
use OC\SystemConfig;
diff --git a/lib/private/Log/LogDetails.php b/lib/private/Log/LogDetails.php
index 1175b475302..5ca8231eecb 100644
--- a/lib/private/Log/LogDetails.php
+++ b/lib/private/Log/LogDetails.php
@@ -15,14 +15,13 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
namespace OC\Log;
use OC\SystemConfig;
@@ -83,13 +82,17 @@ abstract class LogDetails {
'version'
);
- if (is_array($message) && !array_key_exists('Exception', $message)) {
- // Exception messages should stay as they are,
+ if (is_array($message)) {
+ // Exception messages are extracted and the exception is put into a separate field
// anything else modern is split to 'message' (string) and
// data (array) fields
- $shortMessage = $message['message'] ?? '(no message provided)';
- $entry['data'] = $message;
- $entry['message'] = $shortMessage;
+ if (array_key_exists('Exception', $message)) {
+ $entry['exception'] = $message;
+ $entry['message'] = $message['CustomMessage'] !== '--' ? $message['CustomMessage'] : $message['Message'];
+ } else {
+ $entry['data'] = $message;
+ $entry['message'] = $message['message'] ?? '(no message provided)';
+ }
}
return $entry;
diff --git a/lib/private/Log/LogFactory.php b/lib/private/Log/LogFactory.php
index 6e6ded3758b..f0f804cd51c 100644
--- a/lib/private/Log/LogFactory.php
+++ b/lib/private/Log/LogFactory.php
@@ -15,14 +15,13 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
namespace OC\Log;
use OC\Log;
diff --git a/lib/private/Log/PsrLoggerAdapter.php b/lib/private/Log/PsrLoggerAdapter.php
index 8cd64bfe903..1cf81c49a69 100644
--- a/lib/private/Log/PsrLoggerAdapter.php
+++ b/lib/private/Log/PsrLoggerAdapter.php
@@ -16,14 +16,13 @@ declare(strict_types=1);
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
namespace OC\Log;
use OC\Log;
diff --git a/lib/private/Log/Rotate.php b/lib/private/Log/Rotate.php
index 76d026bc854..58b2932b417 100644
--- a/lib/private/Log/Rotate.php
+++ b/lib/private/Log/Rotate.php
@@ -5,7 +5,6 @@
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <robin@icewind.nl>
*
* @license AGPL-3.0
@@ -23,7 +22,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
namespace OC\Log;
use OCP\Log\RotationTrait;
diff --git a/lib/private/Log/Syslog.php b/lib/private/Log/Syslog.php
index 02cffe066b1..7c3d1a54b78 100644
--- a/lib/private/Log/Syslog.php
+++ b/lib/private/Log/Syslog.php
@@ -5,7 +5,6 @@
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
* @author Bart Visscher <bartv@thisnet.nl>
* @author Julius Härtl <jus@bitgrid.net>
- * @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu>
*
@@ -24,7 +23,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
-
namespace OC\Log;
use OC\SystemConfig;
diff --git a/lib/private/Log/Systemdlog.php b/lib/private/Log/Systemdlog.php
index 979befbdae1..17778891efe 100644
--- a/lib/private/Log/Systemdlog.php
+++ b/lib/private/Log/Systemdlog.php
@@ -16,14 +16,13 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-
namespace OC\Log;
use OC\HintException;