Skip to content

Commit

Permalink
[MonologBridge] Return empty list for unknonwn requests
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL committed Nov 25, 2018
1 parent b178266 commit 69be8e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Monolog/Processor/DebugProcessor.php
Expand Up @@ -60,8 +60,8 @@ public function __invoke(array $record)
*/
public function getLogs(/* Request $request = null */)
{
if (1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) && isset($this->records[$hash = spl_object_hash($request)])) {
return $this->records[$hash];
if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) {
return $this->records[spl_object_hash($request)] ?? array();
}

if (0 === \count($this->records)) {
Expand All @@ -76,8 +76,8 @@ public function getLogs(/* Request $request = null */)
*/
public function countErrors(/* Request $request = null */)
{
if (1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) && isset($this->errorCount[$hash = spl_object_hash($request)])) {
return $this->errorCount[$hash];
if (1 <= \func_num_args() && null !== $request = \func_get_arg(0)) {
return $this->errorCount[spl_object_hash($request)] ?? 0;
}

return array_sum($this->errorCount);
Expand Down
Expand Up @@ -58,6 +58,9 @@ public function testWithRequestStack()

$this->assertCount(2, $processor->getLogs($request));
$this->assertSame(1, $processor->countErrors($request));

$this->assertCount(0, $processor->getLogs(new Request()));
$this->assertSame(0, $processor->countErrors(new Request()));
}

private function getRecord($level = Logger::WARNING, $message = 'test')
Expand Down

0 comments on commit 69be8e6

Please sign in to comment.