manager = $manager; $this->database = $database; $this->writeConcern = $writeConcern; } /** * This writer does not support formatting. * * @param string|FormatterInterface $formatter * @param array|null $options (unused) * @return WriterInterface */ public function setFormatter($formatter, ?array $options = null) { return $this; } /** * Write a message to the log. * * @param array $event Event data * @return void * @throws Exception\RuntimeException */ protected function doWrite(array $event) { if (null === $this->manager) { throw new Exception\RuntimeException('MongoDB\Driver\Manager must be defined'); } if (isset($event['timestamp']) && $event['timestamp'] instanceof DateTimeInterface) { $millis = (int) floor((float) $event['timestamp']->format('U.u') * 1000); $event['timestamp'] = new UTCDateTime($millis); } $bulkWrite = new BulkWrite(); $bulkWrite->insert($event); $this->manager->executeBulkWrite($this->database, $bulkWrite, $this->writeConcern); } }