diff options
Diffstat (limited to 'main/app/sprinkles/core/src/Log')
-rw-r--r-- | main/app/sprinkles/core/src/Log/DatabaseHandler.php | 104 | ||||
-rw-r--r-- | main/app/sprinkles/core/src/Log/MixedFormatter.php | 116 |
2 files changed, 110 insertions, 110 deletions
diff --git a/main/app/sprinkles/core/src/Log/DatabaseHandler.php b/main/app/sprinkles/core/src/Log/DatabaseHandler.php index d4c9fce..49eb5c2 100644 --- a/main/app/sprinkles/core/src/Log/DatabaseHandler.php +++ b/main/app/sprinkles/core/src/Log/DatabaseHandler.php @@ -1,52 +1,52 @@ -<?php -/** - * UserFrosting (http://www.userfrosting.com) - * - * @link https://github.com/userfrosting/UserFrosting - * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License) - */ - -namespace UserFrosting\Sprinkle\Core\Log; - -use Monolog\Logger; -use Monolog\Handler\AbstractProcessingHandler; - -/** - * Monolog handler for storing the record to a database. - * - * @author Alex Weissman (https://alexanderweissman.com) - */ -class DatabaseHandler extends AbstractProcessingHandler -{ - /** - * @var UserFrosting\Sprinkle\Core\Util\ClassMapper - */ - protected $classMapper; - - /** - * @var string - */ - protected $modelIdentifier; - - /** - * Create a new DatabaseHandler object. - * - * @param ClassMapper $classMapper Maps the modelIdentifier to the specific Eloquent model. - * @param string $modelIdentifier - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($classMapper, $modelIdentifier, $level = Logger::DEBUG, $bubble = TRUE) { - $this->classMapper = $classMapper; - $this->modelName = $modelIdentifier; - parent::__construct($level, $bubble); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) { - $log = $this->classMapper->createInstance($this->modelName, $record['extra']); - $log->save(); - } -} +<?php
+/**
+ * UserFrosting (http://www.userfrosting.com)
+ *
+ * @link https://github.com/userfrosting/UserFrosting
+ * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
+ */
+
+namespace UserFrosting\Sprinkle\Core\Log;
+
+use Monolog\Logger;
+use Monolog\Handler\AbstractProcessingHandler;
+
+/**
+ * Monolog handler for storing the record to a database.
+ *
+ * @author Alex Weissman (https://alexanderweissman.com)
+ */
+class DatabaseHandler extends AbstractProcessingHandler
+{
+ /**
+ * @var UserFrosting\Sprinkle\Core\Util\ClassMapper
+ */
+ protected $classMapper;
+
+ /**
+ * @var string
+ */
+ protected $modelIdentifier;
+
+ /**
+ * Create a new DatabaseHandler object.
+ *
+ * @param ClassMapper $classMapper Maps the modelIdentifier to the specific Eloquent model.
+ * @param string $modelIdentifier
+ * @param int $level The minimum logging level at which this handler will be triggered
+ * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
+ */
+ public function __construct($classMapper, $modelIdentifier, $level = Logger::DEBUG, $bubble = TRUE) {
+ $this->classMapper = $classMapper;
+ $this->modelName = $modelIdentifier;
+ parent::__construct($level, $bubble);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function write(array $record) {
+ $log = $this->classMapper->createInstance($this->modelName, $record['extra']);
+ $log->save();
+ }
+}
diff --git a/main/app/sprinkles/core/src/Log/MixedFormatter.php b/main/app/sprinkles/core/src/Log/MixedFormatter.php index ce21879..ef70268 100644 --- a/main/app/sprinkles/core/src/Log/MixedFormatter.php +++ b/main/app/sprinkles/core/src/Log/MixedFormatter.php @@ -1,58 +1,58 @@ -<?php -/** - * UserFrosting (http://www.userfrosting.com) - * - * @link https://github.com/userfrosting/UserFrosting - * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License) - */ - -namespace UserFrosting\Sprinkle\Core\Log; - -use Monolog\Formatter\LineFormatter; - -/** - * Monolog formatter for pretty-printing arrays and objects. - * - * This class extends the basic Monolog LineFormatter class, and provides basically the same functionality but with one exception: - * if the second parameter of any logging method (debug, error, info, etc) is an array, it will print it as a nicely formatted, - * multi-line JSON object instead of all on a single line. - * @author Alex Weissman (https://alexanderweissman.com) - */ -class MixedFormatter extends LineFormatter -{ - - /** - * Return the JSON representation of a value - * - * @param mixed $data - * @param bool $ignoreErrors - * @throws \RuntimeException if encoding fails and errors are not ignored - * @return string - */ - protected function toJson($data, $ignoreErrors = FALSE) { - // suppress json_encode errors since it's twitchy with some inputs - if ($ignoreErrors) { - return @$this->jsonEncodePretty($data); - } - - $json = $this->jsonEncodePretty($data); - - if ($json === FALSE) { - $json = $this->handleJsonError(json_last_error(), $data); - } - - return $json; - } - - /** - * @param mixed $data - * @return string JSON encoded data or null on failure - */ - private function jsonEncodePretty($data) { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); - } - - return json_encode($data); - } -} +<?php
+/**
+ * UserFrosting (http://www.userfrosting.com)
+ *
+ * @link https://github.com/userfrosting/UserFrosting
+ * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
+ */
+
+namespace UserFrosting\Sprinkle\Core\Log;
+
+use Monolog\Formatter\LineFormatter;
+
+/**
+ * Monolog formatter for pretty-printing arrays and objects.
+ *
+ * This class extends the basic Monolog LineFormatter class, and provides basically the same functionality but with one exception:
+ * if the second parameter of any logging method (debug, error, info, etc) is an array, it will print it as a nicely formatted,
+ * multi-line JSON object instead of all on a single line.
+ * @author Alex Weissman (https://alexanderweissman.com)
+ */
+class MixedFormatter extends LineFormatter
+{
+
+ /**
+ * Return the JSON representation of a value
+ *
+ * @param mixed $data
+ * @param bool $ignoreErrors
+ * @throws \RuntimeException if encoding fails and errors are not ignored
+ * @return string
+ */
+ protected function toJson($data, $ignoreErrors = FALSE) {
+ // suppress json_encode errors since it's twitchy with some inputs
+ if ($ignoreErrors) {
+ return @$this->jsonEncodePretty($data);
+ }
+
+ $json = $this->jsonEncodePretty($data);
+
+ if ($json === FALSE) {
+ $json = $this->handleJsonError(json_last_error(), $data);
+ }
+
+ return $json;
+ }
+
+ /**
+ * @param mixed $data
+ * @return string JSON encoded data or null on failure
+ */
+ private function jsonEncodePretty($data) {
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
+ return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
+ }
+
+ return json_encode($data);
+ }
+}
|