public function LoggerIntegrationTest::testLog in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/service_container/Tests/LoggerIntegrationTest.php \Drupal\service_container\Tests\LoggerIntegrationTest::testLog()
File
- lib/
Drupal/ service_container/ Tests/ LoggerIntegrationTest.php, line 32 - Contains \Drupal\service_container\Tests\LoggerIntegrationTest.
Class
Namespace
Drupal\service_container\TestsCode
public function testLog() {
/** @var \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory */
$logger_factory = $this->container
->get('logger.factory');
/** @var \Drupal\Core\Database\Connection $connection */
$connection = $this->container
->get('database');
// Use both the factory and the logger channel directly.
$connection
->truncate('watchdog')
->execute();
$logger_factory
->get('system')
->info('Hello world @key', array(
'@key' => 'value',
));
$this
->doTestEntry($connection);
$connection
->truncate('watchdog')
->execute();
$logger_channel = $this->container
->get('logger.channel.default');
$logger_channel
->info('Hello world @key', array(
'@key' => 'value',
));
$this
->doTestEntry($connection);
}