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

entries() public method

Example: $entries = $logging->entries(); foreach ($entries as $entry) { echo $entry->info()['textPayload'] . PHP_EOL; } Use an advanced logs filter to fetch only entries from a specified log. $entries = $logging->entries([ 'filter' => 'logName = projects/my-project/logs/my-log' ]); 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[] $projectIds A list of projectIds to fetch entries from in addition to entries found in the project bound to this client. @type string[] $resourceNames One or more cloud resources from which to retrieve log entries. Projects listed in projectIds are added to this list. Example: "projects/my-project-1A", "projects/1234567890". @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 = [])
    {
        $options['pageToken'] = null;
        $resourceNames = ['projects/' . $this->projectId];
        if (isset($options['projectIds'])) {
            foreach ($options['projectIds'] as $projectId) {
                $resourceNames[] = 'projects/' . $projectId;
            }
            unset($options['projectIds']);
        }
        if (isset($options['resourceNames'])) {
            $options['resourceNames'] = array_merge($resourceNames, $options['projectIds']);
        } else {
            $options['resourceNames'] = $resourceNames;
        }
        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']);
    }