Google\Cloud\Logging\Logger::entries PHP Method

entries() public method

Please note that a default filter specifying the logName will be applied for you. Example: $entries = $logger->entries(); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; } Use an advanced logs filter to fetch only entries with a specific payload. $entries = $logger->entries([ 'filter' => 'textPayload = "hello world"' ]); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; }
See also: https://cloud.google.com/logging/docs/api/reference/rest/v2/entries/list Entries list API documentation.
public entries ( array $options = [] ) : Generator
$options array [optional] { Configuration options. @type string $filter An [advanced logs filter](https://cloud.google.com/logging/docs/view/advanced_filters). @type string $orderBy How the results should be sorted. Presently, the only permitted values are `timestamp asc` and `timestamp desc`. **Defaults to** `"timestamp asc"`. @type int $pageSize The maximum number of results to return per request. }
return Generator
    public function entries(array $options = [])
    {
        $logNameFilter = "logName = {$this->formattedName}";
        $options += ['pageToken' => null, 'resourceNames' => ["projects/{$this->projectId}"], 'filter' => isset($options['filter']) ? $options['filter'] .= " AND {$logNameFilter}" : $logNameFilter];
        do {
            $response = $this->connection->listEntries($options);
            if (!isset($response['entries'])) {
                return;
            }
            foreach ($response['entries'] as $entry) {
                (yield new Entry($entry));
            }
            $options['pageToken'] = isset($response['nextPageToken']) ? $response['nextPageToken'] : null;
        } while ($options['pageToken']);
    }