From dcb9ffe27d714f3352d4bb4128f34a9954ca6c11 Mon Sep 17 00:00:00 2001 From: Jozhef Date: Fri, 15 Mar 2019 11:16:06 -0700 Subject: [PATCH 1/3] Add listen new config param "minimum_level" error log. --- Factories/RollbarHandlerFactory.php | 45 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/Factories/RollbarHandlerFactory.php b/Factories/RollbarHandlerFactory.php index 852bdb8..c030bd1 100755 --- a/Factories/RollbarHandlerFactory.php +++ b/Factories/RollbarHandlerFactory.php @@ -15,6 +15,11 @@ */ class RollbarHandlerFactory { + /** + * @var string|null + */ + private $minimumLevel; + /** * RollbarHandlerFactory constructor. * @@ -30,30 +35,26 @@ public function __construct(ContainerInterface $container) if (!empty($config['person_fn']) && is_callable($config['person_fn'])) { $config['person'] = null; - } else { - - if (empty($config['person'])) { - - $config['person_fn'] = function() use ($container) { - - try { - $token = $container->get('security.token_storage')->getToken(); - - if ($token) { - $user = $token->getUser(); - $serializer = $container->get('serializer'); - $person = \json_decode($serializer->serialize($user, 'json'), true); - return $person; - } - } catch (\Exception $exception) { - // Ignore + } elseif (empty($config['person'])) { + $config['person_fn'] = function () use ($container) { + + try { + $token = $container->get('security.token_storage')->getToken(); + + if ($token) { + $user = $token->getUser(); + $serializer = $container->get('serializer'); + + return \json_decode($serializer->serialize($user, 'json'), true); } - }; - - } - + } catch (\Exception $exception) { + // Ignore + } + }; } + $this->minimumLevel = $config['minimum_level'] ?: LogLevel::ERROR; + Rollbar::init($config, false, false, false); } @@ -64,6 +65,6 @@ public function __construct(ContainerInterface $container) */ public function createRollbarHandler() { - return new RollbarHandler(Rollbar::logger(), LogLevel::ERROR); + return new RollbarHandler(Rollbar::logger(), $this->minimumLevel); } } From 1cec8e1b536066e70e94b87e8da1533eaaa71166 Mon Sep 17 00:00:00 2001 From: Jozhef Date: Mon, 18 Mar 2019 09:18:13 +0200 Subject: [PATCH 2/3] Change config name to monolog_minimum_level. --- Factories/RollbarHandlerFactory.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Factories/RollbarHandlerFactory.php b/Factories/RollbarHandlerFactory.php index c030bd1..621c833 100755 --- a/Factories/RollbarHandlerFactory.php +++ b/Factories/RollbarHandlerFactory.php @@ -18,7 +18,7 @@ class RollbarHandlerFactory /** * @var string|null */ - private $minimumLevel; + private $monologMinimumLevel; /** * RollbarHandlerFactory constructor. @@ -53,7 +53,9 @@ public function __construct(ContainerInterface $container) }; } - $this->minimumLevel = $config['minimum_level'] ?: LogLevel::ERROR; + $this->monologMinimumLevel = isset($config['monolog_minimum_level']) + ? $config['monolog_minimum_level'] + : LogLevel::ERROR; Rollbar::init($config, false, false, false); } @@ -65,6 +67,6 @@ public function __construct(ContainerInterface $container) */ public function createRollbarHandler() { - return new RollbarHandler(Rollbar::logger(), $this->minimumLevel); + return new RollbarHandler(Rollbar::logger(), $this->monologMinimumLevel); } } From 6aed6c754f3dbc827f0f07938b2d98bc95407a1e Mon Sep 17 00:00:00 2001 From: Jozhef Date: Mon, 18 Mar 2019 09:43:37 +0200 Subject: [PATCH 3/3] Change config name to monolog_minimum_level. --- Factories/RollbarHandlerFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Factories/RollbarHandlerFactory.php b/Factories/RollbarHandlerFactory.php index c030bd1..e6d719f 100755 --- a/Factories/RollbarHandlerFactory.php +++ b/Factories/RollbarHandlerFactory.php @@ -53,7 +53,7 @@ public function __construct(ContainerInterface $container) }; } - $this->minimumLevel = $config['minimum_level'] ?: LogLevel::ERROR; + $this->minimumLevel = isset($config['minimum_level']) ? $config['minimum_level'] : LogLevel::ERROR; Rollbar::init($config, false, false, false); }