You are here

public function Logger::__construct in MongoDB 8.2

Logger constructor.

Parameters

\MongoDB\Database $database: The database object.

\Drupal\Core\Logger\LogMessageParserInterface $parser: The parser to use when extracting message variables.

\Drupal\Core\Config\ConfigFactoryInterface $configFactory: The core config_factory service.

\Symfony\Component\HttpFoundation\RequestStack $stack: The core request_stack service.

\Drupal\Core\Messenger\MessengerInterface $messenger: The messenger service.

\Drupal\Component\Datetime\TimeInterface $time: The datetime.time service.

1 method overrides Logger::__construct()
MockLogger::__construct in modules/mongodb_watchdog/tests/src/Unit/MockLogger.php
TestLogger mock constructor.

File

modules/mongodb_watchdog/src/Logger.php, line 203

Class

Logger
Class Logger is a PSR/3 Logger using a MongoDB data store.

Namespace

Drupal\mongodb_watchdog

Code

public function __construct(Database $database, LogMessageParserInterface $parser, ConfigFactoryInterface $configFactory, RequestStack $stack, MessengerInterface $messenger, TimeInterface $time) {
  $this->database = $database;
  $this->messenger = $messenger;
  $this->parser = $parser;
  $this->requestStack = $stack;
  $this->time = $time;
  $config = $configFactory
    ->get(static::CONFIG_NAME);

  // During install, a logger will be invoked 3 times, the first 2 without any
  // configuration information, so hard-coded defaults are needed on all
  // config keys.
  $this
    ->setLimit($config
    ->get(static::CONFIG_LIMIT) ?? RfcLogLevel::DEBUG);

  // Do NOT use 1E4 / 1E5: these are doubles, but config is typed to integers.
  $this->items = $config
    ->get(static::CONFIG_ITEMS) ?? 10000;
  $this->requests = $config
    ->get(static::CONFIG_REQUESTS) ?? 100000;
  $this->requestTracking = $config
    ->get(static::CONFIG_REQUEST_TRACKING) ?? FALSE;
}