Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获得';页面大小';Google云平台Stackdriver Logging API中的选项,用于返回带有下一页标记的分页条目_Php_Logging_Google Cloud Platform_Stackdriver_Google Cloud Stackdriver - Fatal编程技术网

Php 如何获得';页面大小';Google云平台Stackdriver Logging API中的选项,用于返回带有下一页标记的分页条目

Php 如何获得';页面大小';Google云平台Stackdriver Logging API中的选项,用于返回带有下一页标记的分页条目,php,logging,google-cloud-platform,stackdriver,google-cloud-stackdriver,Php,Logging,Google Cloud Platform,Stackdriver,Google Cloud Stackdriver,当我通过此处的控制台测试窗口输入请求时: 我设置了page size参数,并返回正确数量的条目以及下一页标记。但是,当我通过PHP Cloud API将此选项设置为entries请求的参数时,它只返回未分页的结果;忽略页面大小限制 这是PHPAPI的问题吗?有人找到了解决这个问题的方法吗 putenv('GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_JSON_FILE'); $client = new Google_Client(); $client->

当我通过此处的控制台测试窗口输入请求时:

我设置了page size参数,并返回正确数量的条目以及下一页标记。但是,当我通过PHP Cloud API将此选项设置为entries请求的参数时,它只返回未分页的结果;忽略页面大小限制

这是PHPAPI的问题吗?有人找到了解决这个问题的方法吗

putenv('GOOGLE_APPLICATION_CREDENTIALS=PATH_TO_JSON_FILE');


$client = new Google_Client();
$client->useApplicationDefaultCredentials();


$this->loggingClient = new LoggingClient([
    'projectId' => PROJECT_ID
]);

// Get a logger instance.
$logger = $this->loggingClient->logger(LOGGER);

$options = array(
    'pageSize' => 100,
    'orderBy' => 'timestamp desc',
    'filter' => FILTER,
);
$entries = $this->loggingClient->entries($options);
$logs = array();
foreach ($entries as $entry) {
...

默认情况下,从
LoggingClient::entries()
返回的迭代器将在您迭代时为您分页。事实上,每个请求只向服务器请求100个日志,这对您来说是透明的:)

如果您想快速获得一页结果,我们还支持以下内容:

$entries = $client->entries([
    'pageSize' => 100
]);

foreach ($entries->iterateByPage() as $page) {
    print count($page); // Should be 100
}
希望这有帮助

$entries = $client->entries([
    'pageSize' => 100
]);

foreach ($entries->iterateByPage() as $page) {
    print count($page); // Should be 100
}