Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'utility/smarterlogger.php')
-rw-r--r--utility/smarterlogger.php52
1 files changed, 30 insertions, 22 deletions
diff --git a/utility/smarterlogger.php b/utility/smarterlogger.php
index 261793ac..4cc2e11c 100644
--- a/utility/smarterlogger.php
+++ b/utility/smarterlogger.php
@@ -184,15 +184,11 @@ class SmarterLogger implements ILogger {
return $data;
}
- if (is_array($data) || $data instanceof \Traversable) {
+ if ($this->normalizeTraversable($data)) {
return $this->normalizeTraversable($data);
}
- if (is_object($data)) {
- if ($data instanceof \Exception) {
- return $this->normalizeException($data);
- }
-
+ if ($this->normalizeObject($data)) {
return $this->normalizeObject($data);
}
@@ -211,19 +207,23 @@ class SmarterLogger implements ILogger {
* @return string
*/
private function normalizeTraversable($data) {
- $normalized = array();
- $count = 1;
- foreach ($data as $key => $value) {
- if ($count >= 1000) {
- $normalized['...'] =
- 'Over 1000 items, aborting normalization';
- break;
+ if (is_array($data) || $data instanceof \Traversable) {
+ $normalized = array();
+ $count = 1;
+ foreach ($data as $key => $value) {
+ if ($count >= 1000) {
+ $normalized['...'] =
+ 'Over 1000 items, aborting normalization';
+ break;
+ }
+ $normalized[$key] = $this->normalize($value);
}
- $normalized[$key] = $this->normalize($value);
+
+ //return $normalized;
+ return $this->toJson($normalized);
}
- //return $normalized;
- return $this->toJson($normalized);
+ return null;
}
/**
@@ -234,13 +234,21 @@ class SmarterLogger implements ILogger {
* @return string
*/
private function normalizeObject($data) {
- $arrayObject = new \ArrayObject($data);
- $serializedObject = $arrayObject->getArrayCopy();
+ if (is_object($data)) {
+ if ($data instanceof \Exception) {
+ return $this->normalizeException($data);
+ }
- return sprintf(
- "[object] (%s: %s)", get_class($data),
- $this->toJson($serializedObject)
- );
+ $arrayObject = new \ArrayObject($data);
+ $serializedObject = $arrayObject->getArrayCopy();
+
+ return sprintf(
+ "[object] (%s: %s)", get_class($data),
+ $this->toJson($serializedObject)
+ );
+ }
+
+ return null;
}
/**