Skip to content

Commit

Permalink
Allow default listeners to not also log scoped ones.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Scherer committed Mar 2, 2015
1 parent f786cbc commit 4dbf9ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Log/Engine/BaseLog.php
Expand Up @@ -46,7 +46,7 @@ public function __construct(array $config = [])
{
$this->config($config);

if (!is_array($this->_config['scopes'])) {
if (!is_array($this->_config['scopes']) && $this->_config['scopes'] !== false) {
$this->_config['scopes'] = (array)$this->_config['scopes'];
}

Expand Down
6 changes: 5 additions & 1 deletion src/Log/Log.php
Expand Up @@ -367,9 +367,13 @@ public static function write($level, $message, $context = [])
$levels = $logger->levels();
$scopes = $logger->scopes();
}
if ($scopes === null) {
$scopes = [];
}

$correctLevel = empty($levels) || in_array($level, $levels);
$inScope = empty($scopes) || array_intersect($context['scope'], $scopes);
$inScope = $scopes === false && empty($context['scope']) || $scopes === [] ||
is_array($scopes) && array_intersect($context['scope'], $scopes);

if ($correctLevel && $inScope) {
$logger->log($level, $message, $context);
Expand Down

0 comments on commit 4dbf9ee

Please sign in to comment.