diff --git a/src/Config.php b/src/Config.php index 49f49d82..835431c2 100644 --- a/src/Config.php +++ b/src/Config.php @@ -56,7 +56,8 @@ class Config 'include_raw_request_body', 'local_vars_dump', 'max_nesting_depth', - 'max_items' + 'max_items', + 'monolog_minimum_level' ); private $accessToken; @@ -88,7 +89,7 @@ class Config * @var FilterInterface */ private $filter; - private $minimumLevel; + private $monologMinimumLevel; /** * @var ResponseHandlerInterface */ @@ -209,7 +210,7 @@ protected function updateConfig($config) $this->setAccessToken($config); $this->setDataBuilder($config); $this->setTransformer($config); - $this->setMinimumLevel($config); + $this->setMonologMinimumLevel($config); $this->setReportSuppressed($config); $this->setFilters($config); $this->setSender($config); @@ -299,20 +300,20 @@ private function setTransformer($config) $this->setupWithOptions($config, "transformer", $expected); } - private function setMinimumLevel($config) + private function setMonologMinimumLevel($config) { - $this->minimumLevel = 0; - if (empty($config['minimumLevel'])) { - $this->minimumLevel = 0; - } elseif ($config['minimumLevel'] instanceof Level) { - $this->minimumLevel = $config['minimumLevel']->toInt(); - } elseif (is_string($config['minimumLevel'])) { - $level = $this->levelFactory->fromName($config['minimumLevel']); + $this->monologMinimumLevel = 0; + if (empty($config['monologMinimumLevel'])) { + $this->monologMinimumLevel = 0; + } elseif ($config['monologMinimumLevel'] instanceof Level) { + $this->monologMinimumLevel = $config['monologMinimumLevel']->toInt(); + } elseif (is_string($config['monologMinimumLevel'])) { + $level = $this->levelFactory->fromName($config['monologMinimumLevel']); if ($level !== null) { - $this->minimumLevel = $level->toInt(); + $this->monologMinimumLevel = $level->toInt(); } - } elseif (is_int($config['minimumLevel'])) { - $this->minimumLevel = $config['minimumLevel']; + } elseif (is_int($config['monologMinimumLevel'])) { + $this->monologMinimumLevel = $config['monologMinimumLevel']; } } @@ -600,6 +601,11 @@ public function getMaxItems() return $this->maxItems; } + public function getMonologMinimumLevel() + { + return $this->monologMinimumLevel; + } + /** * @param Payload $payload * @param Level $level @@ -802,7 +808,7 @@ private function payloadLevelTooLow($payload) */ private function levelTooLow($level) { - return $level->toInt() < $this->minimumLevel; + return $level->toInt() < $this->monologMinimumLevel; } private function shouldSuppress() diff --git a/src/Defaults.php b/src/Defaults.php index df7f6fb4..37fa1315 100644 --- a/src/Defaults.php +++ b/src/Defaults.php @@ -1,6 +1,6 @@ maxItems; } + public function monologMinimumLevel($value = null) + { + return $value !== null ? $value : $this->monologMinimumLevel; + } + private $psrLevels; private $errorLevels; private $autodetectBranch = false; @@ -358,4 +363,5 @@ public function maxItems($value = null) private $scrubFields; private $customTruncation = null; private $maxItems = 10; + private $monologMinimumLevel = Logger::ERROR; } diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index 62d34acc..e073e139 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -150,19 +150,19 @@ public function testTransformer() $this->assertEquals($pPrime, $config->transform($p, "error", "message", "extra_data")); } - public function testMinimumLevel() + public function testMonologMinimumLevel() { $c = new Config(array( - "access_token" => $this->getTestAccessToken(), - "environment" => $this->env, - "minimumLevel" => "warning" + 'access_token' => $this->getTestAccessToken(), + 'environment' => $this->env, + 'monologMinimumLevel' => 'warning' )); $this->runConfigTest($c); - $c->configure(array("minimumLevel" => Level::WARNING)); + $c->configure(array('monologMinimumLevel' => Level::WARNING)); $this->runConfigTest($c); - $c->configure(array("minimumLevel" => Level::WARNING()->toInt())); + $c->configure(array('monologMinimumLevel' => Level::WARNING()->toInt())); $this->runConfigTest($c); }