OSS\OssClient::getBucketLogging PHP Method

getBucketLogging() public method

获取Bucket的访问日志配置情况
public getBucketLogging ( string $bucket, array $options = NULL ) : OSS\Model\LoggingConfig
$bucket string bucket名称
$options array 可以为空
return OSS\Model\LoggingConfig
    public function getBucketLogging($bucket, $options = NULL)
    {
        $this->precheckCommon($bucket, NULL, $options, false);
        $options[self::OSS_BUCKET] = $bucket;
        $options[self::OSS_METHOD] = self::OSS_HTTP_GET;
        $options[self::OSS_OBJECT] = '/';
        $options[self::OSS_SUB_RESOURCE] = 'logging';
        $response = $this->auth($options);
        $result = new GetLoggingResult($response);
        return $result->getData();
    }

Usage Example

/**
 * 获取bucket的Logging配置
 *
 * @param OssClient $ossClient OssClient实例
 * @param string $bucket 存储空间名称
 * @return null
 */
function getBucketLogging($ossClient, $bucket)
{
    $loggingConfig = null;
    $options = array();
    try {
        $loggingConfig = $ossClient->getBucketLogging($bucket, $options);
    } catch (OssException $e) {
        printf(__FUNCTION__ . ": FAILED\n");
        printf($e->getMessage() . "\n");
        return;
    }
    print __FUNCTION__ . ": OK" . "\n";
    print $loggingConfig->serializeToXml() . "\n";
}