Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions system/Debug/Toolbar/Collectors/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ protected function collectLogs()
return $this->data;
}

$cache = service('logger')->logCache;
$logger = service('logger');

$this->data = $cache ?? [];
if (! property_exists($logger, 'logCache')) {
return $this->data;
}

$this->data = $logger->logCache;

return $this->data;
}
Expand Down
16 changes: 16 additions & 0 deletions tests/system/Debug/Toolbar/Collectors/LogsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use Config\Logger as LoggerConfig;
use Config\Services;
use PHPUnit\Framework\Attributes\Group;
use Psr\Log\AbstractLogger;
use Stringable;

/**
* @internal
Expand Down Expand Up @@ -68,4 +70,18 @@ public function testNotEmpty(): void
$collector = new Logs();
$this->assertFalse($collector->isEmpty());
}

public function testEmptyWithThirdPartyLogger(): void
{
Services::injectMock('logger', new class () extends AbstractLogger {
public function log($level, string|Stringable $message, array $context = []): void
{
}
});

$collector = new Logs();

$this->assertTrue($collector->isEmpty());
$this->assertSame(['logs' => []], $collector->display());
}
}
1 change: 1 addition & 0 deletions user_guide_src/source/changelogs/v4.7.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Bugs Fixed
- **Common:** Fixed a bug where the ``command()`` helper function did not properly clean up output buffers, which could lead to risky tests when exceptions were thrown.
- **Database:** Fixed a bug where the SQLSRV driver's decrement method was adding instead of subtracting the decrement value when ``$castTextToInt`` was false.
- **Kint:** Fixed a bug where stale Content Security Policy nonces were reused in worker mode, causing browser CSP violations for Debug Toolbar assets.
- **Toolbar:** Fixed a bug where the Logs collector raised an undefined property error when using a third-party PSR-3 logger.
- **Time:** Fixed a bug where ``Time::createFromTimestamp()`` could fail for microsecond timestamps when ``LC_NUMERIC`` used a comma decimal separator.
- **Validation:** Fixed a bug where ``Validation::getValidated()`` dropped fields whose validated value was explicitly ``null``.

Expand Down
Loading