/** * @covers ::log() * @covers ::setLoggers() */ public function test_setLoggers() { $logger1 = \Mockery::mock('Psr\\Log\\LoggerInterface'); $logger2 = \Mockery::mock('Psr\\Log\\LoggerInterface'); // Note: We use globally()/ordered() in order to ensure that $logger2 is // called first. $logger2->shouldReceive('log')->globally()->ordered()->with(LogLevel::INFO, 'test-message', array('key' => 'value', 'channel' => 'test')); $logger1->shouldReceive('log')->globally()->ordered()->with(LogLevel::INFO, 'test-message', array('key' => 'value', 'channel' => 'test')); $this->loggerChannel->setLoggers(array(0 => array($logger1), 10 => array($logger2))); $this->loggerChannel->log(LogLevel::INFO, 'test-message', array('key' => 'value')); }
/** * {@inheritdoc} */ public function get($channel) { if (!isset($this->channels[$channel])) { $instance = new LoggerChannel($channel); // Pass the loggers to the channel. $instance->setLoggers($this->loggers); $this->channels[$channel] = $instance; } return $this->channels[$channel]; }