You are here

public function LoggerIntegrationTest::testLog in Service Container 7.2

Same name and namespace in other branches
  1. 7 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

LoggerIntegrationTest

Namespace

Drupal\service_container\Tests

Code

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);
}