Skip to content

Commit

Permalink
NanoLoggerTest: assert that NanoLogger::pushHandler() does register a…
Browse files Browse the repository at this point in the history
… global handler
  • Loading branch information
macbre committed Aug 9, 2023
1 parent 6501933 commit a014e6d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tests/NanoLoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ class NanoLoggerTest extends \Nano\NanoBaseTest
{
public function testGetLogger(): void
{
// register a global logging handler for easier testing
$handler = new TestLoggingHandler(ident: 'foo');
NanoLogger::pushHandler($handler);

$logger = NanoLogger::getLogger(name: __CLASS__, extraFields: ['foo'=>'bar']);
$this->assertInstanceOf(Logger::class, $logger);
$this->assertEquals(__CLASS__, $logger->getName());

// now, let's assert on what's getting logged
$handler = new TestLoggingHandler(ident: 'foo');
$logger->pushHandler($handler);

$logger->info('Message');
$this->assertInstanceOf(LogRecord::class, $handler->lastRecord);

Expand Down

0 comments on commit a014e6d

Please sign in to comment.