PHP Class Google\Cloud\Logging\V2\LoggingServiceV2Client

EXPERIMENTAL: this client library class has not yet been declared beta. This class may change more frequently than those which have been declared beta or 1.0, including changes which break backwards compatibility. This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started: try { $loggingServiceV2Client = new LoggingServiceV2Client(); $formattedLogName = LoggingServiceV2Client::formatLogName("[PROJECT]", "[LOG]"); $loggingServiceV2Client->deleteLog($formattedLogName); } finally { if (isset($loggingServiceV2Client)) { $loggingServiceV2Client->close(); } } Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
Datei anzeigen Open project: GoogleCloudPlatform/gcloud-php

Public Methods

Method Description
__construct ( array $options = [] ) Constructor.
close ( ) Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
deleteLog ( string $logName, array $optionalArgs = [] ) Deletes all the log entries in a log.
formatLogName ( $project, $log ) Formats a string containing the fully-qualified path to represent a log resource.
formatProjectName ( $project ) Formats a string containing the fully-qualified path to represent a project resource.
listLogEntries ( string[] $resourceNames, array $optionalArgs = [] ) : Google\GAX\PagedListResponse Lists log entries. Use this method to retrieve log entries from Cloud Logging. For ways to export log entries, see Exporting Logs.
listMonitoredResourceDescriptors ( array $optionalArgs = [] ) : Google\GAX\PagedListResponse Lists the monitored resource descriptors used by Stackdriver Logging.
parseLogFromLogName ( $logName ) Parses the log from the given fully-qualified path which represents a log resource.
parseProjectFromLogName ( $logName ) Parses the project from the given fully-qualified path which represents a log resource.
parseProjectFromProjectName ( $projectName ) Parses the project from the given fully-qualified path which represents a project resource.
writeLogEntries ( google\logging\v2\LogEntry[] $entries, array $optionalArgs = [] ) : google\logging\v2\WriteLogEntriesResponse Writes log entries to Stackdriver Logging. All log entries are written by this method.

Private Methods

Method Description
createCredentialsCallback ( )
getLogNameTemplate ( )
getPageStreamingDescriptors ( )
getProjectNameTemplate ( )

Method Details

__construct() public method

Constructor.
public __construct ( array $options = [] )
$options array { Optional. Options for configuring the service API wrapper. @type string $serviceAddress The domain name of the API remote host. Default 'logging.googleapis.com'. @type mixed $port The port on which to connect to the remote host. Default 443. @type Grpc\ChannelCredentials $sslCreds A `ChannelCredentials` for use with an SSL-enabled channel. Default: a credentials object returned from Grpc\ChannelCredentials::createSsl() @type array $scopes A string array of scopes to use when acquiring credentials. Default the scopes for the Stackdriver Logging API. @type array $retryingOverride An associative array of string => RetryOptions, where the keys are method names (e.g. 'createFoo'), that overrides default retrying settings. A value of null indicates that the method in question should not retry. @type int $timeoutMillis The timeout in milliseconds to use for calls that don't use retries. For calls that use retries, set the timeout in RetryOptions. Default: 30000 (30 seconds) @type string $appName The codename of the calling service. Default 'gax'. @type string $appVersion The version of the calling service. Default: the current version of GAX. @type Google\Auth\CredentialsLoader $credentialsLoader A CredentialsLoader object created using the Google\Auth library. }

close() public method

Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
public close ( )

deleteLog() public method

The log reappears if it receives new entries. Sample code: try { $loggingServiceV2Client = new LoggingServiceV2Client(); $formattedLogName = LoggingServiceV2Client::formatLogName("[PROJECT]", "[LOG]"); $loggingServiceV2Client->deleteLog($formattedLogName); } finally { if (isset($loggingServiceV2Client)) { $loggingServiceV2Client->close(); } }
public deleteLog ( string $logName, array $optionalArgs = [] )
$logName string Required. The resource name of the log to delete: "projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" `[LOG_ID]` must be URL-encoded. For example, `"projects/my-project-id/logs/syslog"`, `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. For more information about log names, see [LogEntry][google.logging.v2.LogEntry].
$optionalArgs array { Optional. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }

formatLogName() public static method

Formats a string containing the fully-qualified path to represent a log resource.
public static formatLogName ( $project, $log )

formatProjectName() public static method

Formats a string containing the fully-qualified path to represent a project resource.
public static formatProjectName ( $project )

listLogEntries() public method

Sample code: try { $loggingServiceV2Client = new LoggingServiceV2Client(); $resourceNames = []; foreach ($loggingServiceV2Client->listLogEntries($resourceNames) as $element) { doThingsWith(element); } } finally { if (isset($loggingServiceV2Client)) { $loggingServiceV2Client->close(); } }
public listLogEntries ( string[] $resourceNames, array $optionalArgs = [] ) : Google\GAX\PagedListResponse
$resourceNames string[] Required. One or more cloud resources from which to retrieve log entries: "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" Projects listed in the `project_ids` field are added to this list.
$optionalArgs array { Optional. @type string[] $projectIds Deprecated. One or more project identifiers or project numbers from which to retrieve log entries. Example: `"my-project-1A"`. If present, these project identifiers are converted to resource format and added to the list of resources in `resourceNames`. Callers should use `resourceNames` rather than this parameter. @type string $filter Optional. A filter that chooses which log entries to return. See [Advanced Logs Filters](/logging/docs/view/advanced_filters). Only log entries that match the filter are returned. An empty filter matches all log entries. The maximum length of the filter is 20000 characters. @type string $orderBy Optional. How the results should be sorted. Presently, the only permitted values are `"timestamp asc"` (default) and `"timestamp desc"`. The first option returns entries in order of increasing values of `LogEntry.timestamp` (oldest first), and the second option returns entries in order of decreasing timestamps (newest first). Entries with equal timestamps are returned in order of `LogEntry.insertId`. @type int $pageSize The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. @type string $pageToken A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return Google\GAX\PagedListResponse

listMonitoredResourceDescriptors() public method

Sample code: try { $loggingServiceV2Client = new LoggingServiceV2Client(); foreach ($loggingServiceV2Client->listMonitoredResourceDescriptors() as $element) { doThingsWith(element); } } finally { if (isset($loggingServiceV2Client)) { $loggingServiceV2Client->close(); } }
public listMonitoredResourceDescriptors ( array $optionalArgs = [] ) : Google\GAX\PagedListResponse
$optionalArgs array { Optional. @type int $pageSize The maximum number of resources contained in the underlying API response. The API may return fewer values in a page, even if there are additional values to be retrieved. @type string $pageToken A page token is used to specify a page of values to be returned. If no page token is specified (the default), the first page of values will be returned. Any page token used here must have been generated by a previous call to the API. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return Google\GAX\PagedListResponse

parseLogFromLogName() public static method

Parses the log from the given fully-qualified path which represents a log resource.
public static parseLogFromLogName ( $logName )

parseProjectFromLogName() public static method

Parses the project from the given fully-qualified path which represents a log resource.
public static parseProjectFromLogName ( $logName )

parseProjectFromProjectName() public static method

Parses the project from the given fully-qualified path which represents a project resource.
public static parseProjectFromProjectName ( $projectName )

writeLogEntries() public method

Sample code: try { $loggingServiceV2Client = new LoggingServiceV2Client(); $entries = []; $response = $loggingServiceV2Client->writeLogEntries($entries); } finally { if (isset($loggingServiceV2Client)) { $loggingServiceV2Client->close(); } }
public writeLogEntries ( google\logging\v2\LogEntry[] $entries, array $optionalArgs = [] ) : google\logging\v2\WriteLogEntriesResponse
$entries google\logging\v2\LogEntry[] Required. The log entries to write. Values supplied for the fields `log_name`, `resource`, and `labels` in this `entries.write` request are added to those log entries that do not provide their own values for the fields. To improve throughput and to avoid exceeding the [quota limit](/logging/quota-policy) for calls to `entries.write`, you should write multiple log entries at once rather than calling this method for each individual log entry.
$optionalArgs array { Optional. @type string $logName Optional. A default log resource name that is assigned to all log entries in `entries` that do not specify a value for `log_name`: "projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" `[LOG_ID]` must be URL-encoded. For example, `"projects/my-project-id/logs/syslog"` or `"organizations/1234567890/logs/cloudresourcemanager.googleapis.com%2Factivity"`. For more information about log names, see [LogEntry][google.logging.v2.LogEntry]. @type MonitoredResource $resource Optional. A default monitored resource object that is assigned to all log entries in `entries` that do not specify a value for `resource`. Example: { "type": "gce_instance", "labels": { "zone": "us-central1-a", "instance_id": "00000000000000000000" }} See [LogEntry][google.logging.v2.LogEntry]. @type array $labels Optional. Default labels that are added to the `labels` field of all log entries in `entries`. If a log entry already has a label with the same key as a label in this parameter, then the log entry's label is not changed. See [LogEntry][google.logging.v2.LogEntry]. @type bool $partialSuccess Optional. Whether valid entries should be written even if some other entries fail due to INVALID_ARGUMENT or PERMISSION_DENIED errors. If any entry is not written, the response status will be the error associated with one of the failed entries and include error details in the form of WriteLogEntriesPartialErrors. @type \Google\GAX\RetrySettings $retrySettings Retry settings to use for this call. If present, then $timeoutMillis is ignored. @type int $timeoutMillis Timeout to use for this call. Only used if $retrySettings is not set. }
return google\logging\v2\WriteLogEntriesResponse