本文整理汇总了PHP中Google_Client::getLogger方法的典型用法代码示例。如果您正苦于以下问题:PHP Google_Client::getLogger方法的具体用法?PHP Google_Client::getLogger怎么用?PHP Google_Client::getLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google_Client
的用法示例。
在下文中一共展示了Google_Client::getLogger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(Google_Client $client)
{
if (!function_exists('memcache_connect') && !class_exists("Memcached")) {
$error = "Memcache functions not available";
$client->getLogger()->error($error);
//throw new Google_Cache_Exception($error);
echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => $error, 'map' => ''));
die;
}
$this->client = $client;
if ($client->isAppEngine()) {
// No credentials needed for GAE.
$this->mc = new Memcached();
$this->connection = true;
} else {
$this->host = $client->getClassConfig($this, 'host');
$this->port = $client->getClassConfig($this, 'port');
if (empty($this->host) || empty($this->port) && (string) $this->port != "0") {
$error = "You need to supply a valid memcache host and port";
$client->getLogger()->error($error);
//throw new Google_Cache_Exception($error);
echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => $error, 'map' => ''));
die;
}
}
}
示例2: fetchResumeUri
private function fetchResumeUri()
{
$result = null;
$body = $this->request->getBody();
if ($body) {
$headers = array('content-type' => 'application/json; charset=UTF-8', 'content-length' => $body->getSize(), 'x-upload-content-type' => $this->mimeType, 'x-upload-content-length' => $this->size, 'expect' => '');
foreach ($headers as $key => $value) {
$this->request->setHeader($key, $value);
}
}
$response = $this->client->getHttpClient()->send($this->request);
$location = $response->getHeader('location');
$code = $response->getStatusCode();
if (200 == $code && true == $location) {
return $location;
}
$message = $code;
$body = $response->json();
if (isset($body['error']['errors'])) {
$message .= ': ';
foreach ($body['error']['errors'] as $error) {
$message .= "{$error[domain]}, {$error[message]};";
}
$message = rtrim($message, ';');
}
$error = "Failed to start the resumable upload (HTTP {$message})";
$this->client->getLogger()->error($error);
throw new Google_Exception($error);
}
示例3: getResumeUri
private function getResumeUri()
{
$result = null;
$body = $this->request->getPostBody();
if ($body) {
$headers = array('content-type' => 'application/json; charset=UTF-8', 'content-length' => Google_Utils::getStrLen($body), 'x-upload-content-type' => $this->mimeType, 'x-upload-content-length' => $this->size, 'expect' => '');
$this->request->setRequestHeaders($headers);
}
$response = $this->client->getIo()->makeRequest($this->request);
$location = $response->getResponseHeader('location');
$code = $response->getResponseHttpCode();
if (200 == $code && true == $location) {
return $location;
}
$message = $code;
$body = @json_decode($response->getResponseBody());
if (!empty($body->error->errors)) {
$message .= ': ';
foreach ($body->error->errors as $error) {
$message .= "{$error->domain}, {$error->message};";
}
$message = rtrim($message, ';');
}
$error = "Failed to start the resumable upload (HTTP {$message})";
$this->client->getLogger()->error($error);
throw new Google_Exception($error);
}
示例4: __construct
public function __construct(Google_Client $client)
{
if (!function_exists('apc_add')) {
$error = "Apc functions not available";
$client->getLogger()->error($error);
throw new Google_Cache_Exception($error);
}
$this->client = $client;
}
示例5: __construct
public function __construct(Google_Client $client)
{
if (!class_exists('Guzzle\\Http\\Client')) {
$error = 'Cannot find class Guzzle\\Http\\Client';
$client->getLogger()->critical($error);
throw new Google_IO_Exception($error);
}
parent::__construct($client);
}
示例6: __construct
public function __construct(Google_Client $client)
{
if (!extension_loaded('curl')) {
$error = 'The cURL IO handler requires the cURL extension to be enabled';
$client->getLogger()->critical($error);
throw new Google_IO_Exception($error);
}
parent::__construct($client);
}
示例7: __construct
public function __construct(Google_Client $client)
{
if (!ini_get('allow_url_fopen')) {
$error = 'The stream IO handler requires the allow_url_fopen runtime ' . 'configuration to be enabled';
$client->getLogger()->critical($error);
throw new Google_IO_Exception($error);
}
parent::__construct($client);
}
示例8: __construct
public function __construct(Google_Client $client)
{
if (!extension_loaded('curl')) {
$error = 'The cURL IO handler requires the cURL extension to be enabled';
$client->getLogger()->critical($error);
throw new Google_IO_Exception($error);
}
parent::__construct($client);
$this->disableProxyWorkaround = $this->client->getClassConfig('Google_IO_Curl', 'disable_proxy_workaround');
}
示例9: decodeHttpResponse
/**
* Decode an HTTP Response.
*
* @static
*
* @throws Google_Service_Exception
* @param Google_Http_Request $response
* The http response to be decoded.
* @param Google_Client $client
* @return mixed|null
*/
public static function decodeHttpResponse($response, Google_Client $client = null)
{
$code = $response->getResponseHttpCode();
$body = $response->getResponseBody();
$decoded = null;
if (intVal($code) >= 300) {
$decoded = json_decode($body, true);
$err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
if (isset($decoded['error']) && isset($decoded['error']['message']) && isset($decoded['error']['code'])) {
// if we're getting a json encoded error definition, use that instead of the raw response
// body for improved readability
$err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
} else {
$err .= ": ({$code}) {$body}";
}
$errors = null;
// Specific check for APIs which don't return error details, such as Blogger.
if (isset($decoded['error']) && isset($decoded['error']['errors'])) {
$errors = $decoded['error']['errors'];
}
if ($client) {
$client->getLogger()->error($err, array('code' => $code, 'errors' => $errors));
}
throw new Google_Service_Exception($err, $code, null, $errors);
}
// Only attempt to decode the response, if the response code wasn't (204) 'no content'
if ($code != '204') {
$decoded = json_decode($body, true);
if ($decoded === null || $decoded === "") {
$error = "Invalid json in service response: {$body}";
if ($client) {
$client->getLogger()->error($error);
}
throw new Google_Service_Exception($error);
}
if ($response->getExpectedClass()) {
$class = $response->getExpectedClass();
$decoded = new $class($decoded);
}
}
return $decoded;
}
示例10: __construct
public function __construct(Google_Client $client)
{
if (!extension_loaded('curl')) {
$error = 'The cURL IO handler requires the cURL extension to be enabled';
$client->getLogger()->critical($error);
//throw new Google_IO_Exception($error);
echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => $error));
die;
}
parent::__construct($client);
}
示例11: __construct
public function __construct(Google_Client $client)
{
if (!function_exists('apc_add')) {
$error = "Apc functions not available";
$client->getLogger()->error($error);
//throw new Google_Cache_Exception($error);
echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => $error, 'map' => ''));
die;
}
$this->client = $client;
}
示例12: __construct
public function __construct(Google_Client $client)
{
if (!ini_get('allow_url_fopen')) {
$error = 'The stream IO handler requires the allow_url_fopen runtime ' . 'configuration to be enabled';
$client->getLogger()->critical($error);
//throw new Google_IO_Exception($error);
echo json_encode(array('status' => FALSE, 'response-code' => 400, 'response' => $error, 'message' => ''));
die;
}
parent::__construct($client);
}
示例13: __construct
public function __construct(Google_Client $client)
{
if (!function_exists('memcache_connect') && !class_exists("Memcached")) {
$error = "Memcache functions not available";
$client->getLogger()->error($error);
throw new Google_Cache_Exception($error);
}
$this->client = $client;
if ($client->isAppEngine()) {
// No credentials needed for GAE.
$this->mc = new Memcached();
$this->connection = true;
} else {
$this->host = $client->getClassConfig($this, 'host');
$this->port = $client->getClassConfig($this, 'port');
if (empty($this->host) || empty($this->port) && (string) $this->port != "0") {
$error = "You need to supply a valid memcache host and port";
$client->getLogger()->error($error);
throw new Google_Cache_Exception($error);
}
}
}
示例14: call
/**
* TODO: This function needs simplifying.
* @param $name
* @param $arguments
* @param $expected_class - optional, the expected class name
* @return Google_Http_Request|expected_class
* @throws Google_Exception
*/
public function call($name, $arguments, $expected_class = null)
{
if (!isset($this->methods[$name])) {
$this->client->getLogger()->error('Service method unknown', array('service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name));
throw new Google_Exception("Unknown function: " . "{$this->serviceName}->{$this->resourceName}->{$name}()");
}
$method = $this->methods[$name];
$parameters = $arguments[0];
// postBody is a special case since it's not defined in the discovery
// document as parameter, but we abuse the param entry for storing it.
$postBody = null;
if (isset($parameters['postBody'])) {
if ($parameters['postBody'] instanceof Google_Model) {
// In the cases the post body is an existing object, we want
// to use the smart method to create a simple object for
// for JSONification.
$parameters['postBody'] = $parameters['postBody']->toSimpleObject();
} else {
if (is_object($parameters['postBody'])) {
// If the post body is another kind of object, we will try and
// wrangle it into a sensible format.
$parameters['postBody'] = $this->convertToArrayAndStripNulls($parameters['postBody']);
}
}
$postBody = (array) $parameters['postBody'];
unset($parameters['postBody']);
}
// TODO: optParams here probably should have been
// handled already - this may well be redundant code.
if (isset($parameters['optParams'])) {
$optParams = $parameters['optParams'];
unset($parameters['optParams']);
$parameters = array_merge($parameters, $optParams);
}
if (!isset($method['parameters'])) {
$method['parameters'] = array();
}
$method['parameters'] = array_merge($this->stackParameters, $method['parameters']);
foreach ($parameters as $key => $val) {
if ($key != 'postBody' && !isset($method['parameters'][$key])) {
$this->client->getLogger()->error('Service parameter unknown', array('service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name, 'parameter' => $key));
throw new Google_Exception("({$name}) unknown parameter: '{$key}'");
}
}
foreach ($method['parameters'] as $paramName => $paramSpec) {
if (isset($paramSpec['required']) && $paramSpec['required'] && !isset($parameters[$paramName])) {
$this->client->getLogger()->error('Service parameter missing', array('service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name, 'parameter' => $paramName));
throw new Google_Exception("({$name}) missing required param: '{$paramName}'");
}
if (isset($parameters[$paramName])) {
$value = $parameters[$paramName];
$parameters[$paramName] = $paramSpec;
$parameters[$paramName]['value'] = $value;
unset($parameters[$paramName]['required']);
} else {
// Ensure we don't pass nulls.
unset($parameters[$paramName]);
}
}
$this->client->getLogger()->info('Service Call', array('service' => $this->serviceName, 'resource' => $this->resourceName, 'method' => $name, 'arguments' => $parameters));
$url = $this->createRequestUri($method['path'], $parameters);
$http = $this->client->getHttpClient();
$this->client->authorize($http);
// Guzzle 5 cannot locate App Engine certs by default,
// so we tell Guzzle where to look
if ($this->client->isAppEngine()) {
$http->setDefaultOption('verify', '/etc/ca-certificates.crt');
}
$request = $http->createRequest($method['httpMethod'], $url, ['json' => $postBody]);
if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
$expected_class = null;
}
if ($this->client->shouldDefer()) {
// @TODO find a better way to do this
$request->setHeader('X-Php-Expected-Class', $expected_class);
return $request;
}
// support uploads
if (isset($parameters['data'])) {
$mimeType = isset($parameters['mimeType']) ? $parameters['mimeType']['value'] : 'application/octet-stream';
$data = $parameters['data']['value'];
$upload = new Google_Http_MediaFileUpload($this->client, $request, $mimeType, $data);
}
if (isset($parameters['alt']) && $parameters['alt']['value'] == 'media') {
$expected_class = null;
}
return $this->client->execute($request, $expected_class);
}
示例15: backOff
/**
* Sleeps in accordance to the backoff configurations.
*/
private function backOff()
{
$delay = $this->getDelay();
$this->client->getLogger()->debug('Retrying task with backoff', array('request' => $this->name, 'retry' => $this->attempts, 'backoff_seconds' => $delay));
usleep($delay * 1000000);
}