/** * Write a single entry to the log. * * Example: * ``` * // Writing a simple log entry. * $logger->write('a log entry'); * ``` * * ``` * // Writing a simple entry with a key/value set of data and a severity of `EMERGENCY`. * $logger->write(['user' => 'calvin'], [ * 'severity' => Logger::EMERGENCY * ]); * ``` * * ``` * // Using the entry factory method to write a log entry. * $entry = $logger->entry('a log entry'); * $logger->write($entry); * ``` * * @codingStandardsIgnoreStart * @see https://cloud.google.com/logging/docs/api/reference/rest/v2/entries/write Entries write API documentation. * @codingStandardsIgnoreEnd * * @param array|string|Entry $entry The entry to write to the log. * @param array $options [optional] Please see * {@see Google\Cloud\Logging\Logger::entry()} to see the options * that can be applied to a log entry. Please note that if the * provided entry is of type `Entry` these options will overwrite * those that may already be set on the instance. * @throws \InvalidArgumentException */ public function write($entry, array $options = []) { $entryOptions = $this->pluckArray($this->entryOptions, $options); if ($entry instanceof Entry) { if ($entryOptions) { $entry = new Entry($entryOptions + $entry->info()); } } else { $entry = $this->entry($entry, $entryOptions); } $this->writeBatch([$entry], $options); }