Class LoggingServiceV2Client (2.33.0-rc)

Service for ingesting and querying logs.

Equality

Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection> objects compare equal. Objects that compare equal share the same underlying resources.

Performance

Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.

Thread Safety

Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.

Constructors

LoggingServiceV2Client(LoggingServiceV2Client const &)

Copy and move support

Parameter
Name Description
LoggingServiceV2Client const &

LoggingServiceV2Client(LoggingServiceV2Client &&)

Copy and move support

Parameter
Name Description
LoggingServiceV2Client &&

LoggingServiceV2Client(std::shared_ptr< LoggingServiceV2Connection >, Options)

Parameters
Name Description
connection std::shared_ptr< LoggingServiceV2Connection >
opts Options

Operators

operator=(LoggingServiceV2Client const &)

Copy and move support

Parameter
Name Description
LoggingServiceV2Client const &
Returns
Type Description
LoggingServiceV2Client &

operator=(LoggingServiceV2Client &&)

Copy and move support

Parameter
Name Description
LoggingServiceV2Client &&
Returns
Type Description
LoggingServiceV2Client &

Functions

DeleteLog(std::string const &, Options)

Deletes all the log entries in a log for the _Default Log Bucket.

The log reappears if it receives new entries. Log entries written shortly before the delete operation might not be deleted. Entries received after the delete operation with a timestamp before the operation will be deleted.

Parameters
Name Description
log_name std::string const &

Required. The resource name of the log to delete:

  • projects/[PROJECT_ID]/logs/[LOG_ID]
  • organizations/[ORGANIZATION_ID]/logs/[LOG_ID]
  • billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]
  • folders/[FOLDER_ID]/logs/[LOG_ID]
    [LOG_ID] must be URL-encoded. For example, "projects/my-project-id/logs/syslog", "organizations/123/logs/cloudaudit.googleapis.com%2Factivity".
    For more information about log names, see LogEntry.
opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
Status

a Status object. If the request failed, the status contains the details of the failure.

DeleteLog(google::logging::v2::DeleteLogRequest const &, Options)

Deletes all the log entries in a log for the _Default Log Bucket.

The log reappears if it receives new entries. Log entries written shortly before the delete operation might not be deleted. Entries received after the delete operation with a timestamp before the operation will be deleted.

Parameters
Name Description
request google::logging::v2::DeleteLogRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.logging.v2.DeleteLogRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
Status

a Status object. If the request failed, the status contains the details of the failure.

WriteLogEntries(std::string const &, google::api::MonitoredResource const &, std::map< std::string, std::string > const &, std::vector< google::logging::v2::LogEntry > const &, Options)

Writes log entries to Logging.

This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)

Parameters
Name Description
log_name std::string const &

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]
  • billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]
  • folders/[FOLDER_ID]/logs/[LOG_ID]
    [LOG_ID] must be URL-encoded. For example:
    "projects/my-project-id/logs/syslog" "organizations/123/logs/cloudaudit.googleapis.com%2Factivity"
    The permission logging.logEntries.create is needed on each project, organization, billing account, or folder that is receiving new log entries, whether the resource is specified in logName or in an individual log entry.
resource google::api::MonitoredResource const &

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.

labels std::map< std::string, std::string > const &

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.

entries std::vector< google::logging::v2::LogEntry > const &

Required. The log entries to send to Logging. The order of log entries in this list does not matter. Values supplied in this method's log_name, resource, and labels fields are copied into those log entries in this list that do not include values for their corresponding fields.
For more information, see WriteLogEntriesRequest.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StatusOr< google::logging::v2::WriteLogEntriesResponse >

the result of the RPC. The response message type (google.logging.v2.WriteLogEntriesResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

WriteLogEntries(google::logging::v2::WriteLogEntriesRequest const &, Options)

Writes log entries to Logging.

This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)

Parameters
Name Description
request google::logging::v2::WriteLogEntriesRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.logging.v2.WriteLogEntriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StatusOr< google::logging::v2::WriteLogEntriesResponse >

the result of the RPC. The response message type (google.logging.v2.WriteLogEntriesResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

ListLogEntries(std::vector< std::string > const &, std::string const &, std::string const &, Options)

Lists log entries.

Use this method to retrieve log entries that originated from a project/folder/organization/billing account. For ways to export log entries, see Exporting Logs.

Parameters
Name Description
resource_names std::vector< std::string > const &

Required. Names of one or more parent resources from which to retrieve log entries:

  • projects/[PROJECT_ID]
  • organizations/[ORGANIZATION_ID]
  • billingAccounts/[BILLING_ACCOUNT_ID]
  • folders/[FOLDER_ID]
    May alternatively be one or more views:
    • projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
    • organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
    • billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
    • folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]
      Projects listed in the project_ids field are added to this list. A maximum of 100 resources may be specified in a single request.
filter std::string const &

Optional. Only log entries that match the filter are returned. An empty filter matches all log entries in the resources listed in resource_names. Referencing a parent resource that is not listed in resource_names will cause the filter to return no results. The maximum length of a filter is 20,000 characters.

order_by std::string const &

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 their insert_id values.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< google::logging::v2::LogEntry >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.logging.v2.LogEntry, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListLogEntries(google::logging::v2::ListLogEntriesRequest, Options)

Lists log entries.

Use this method to retrieve log entries that originated from a project/folder/organization/billing account. For ways to export log entries, see Exporting Logs.

Parameters
Name Description
request google::logging::v2::ListLogEntriesRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.logging.v2.ListLogEntriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< google::logging::v2::LogEntry >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.logging.v2.LogEntry, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListMonitoredResourceDescriptors(google::logging::v2::ListMonitoredResourceDescriptorsRequest, Options)

Lists the descriptors for monitored resource types used by Logging.

Parameters
Name Description
request google::logging::v2::ListMonitoredResourceDescriptorsRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.logging.v2.ListMonitoredResourceDescriptorsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< google::api::MonitoredResourceDescriptor >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.MonitoredResourceDescriptor, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListLogs(std::string const &, Options)

Lists the logs in projects, organizations, folders, or billing accounts.

Only logs that have entries are listed.

Parameters
Name Description
parent std::string const &

Required. The resource name to list logs for:

  • projects/[PROJECT_ID]
  • organizations/[ORGANIZATION_ID]
  • billingAccounts/[BILLING_ACCOUNT_ID]
  • folders/[FOLDER_ID]
opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< std::string >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains a std::string.

ListLogs(google::logging::v2::ListLogsRequest, Options)

Lists the logs in projects, organizations, folders, or billing accounts.

Only logs that have entries are listed.

Parameters
Name Description
request google::logging::v2::ListLogsRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.logging.v2.ListLogsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< std::string >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains a std::string.

AsyncTailLogEntries(Options)

Streaming read of log entries as they are ingested.

Until the stream is terminated, it will continue reading logs.

Parameter
Name Description
opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
std::unique_ptr<::google::cloud::AsyncStreamingReadWriteRpc< google::logging::v2::TailLogEntriesRequest, google::logging::v2::TailLogEntriesResponse > >

An object representing the bidirectional streaming RPC. Applications can send multiple request messages and receive multiple response messages through this API. Bidirectional streaming RPCs can impose restrictions on the sequence of request and response messages. Please consult the service documentation for details. The request message type (google.logging.v2.TailLogEntriesRequest) and response messages (google.logging.v2.TailLogEntriesResponse) are mapped to C++ classes using the Protobuf mapping rules.

ListOperations(std::string const &, std::string const &, Options)

Lists operations that match the specified filter in the request.

If the server doesn't support this method, it returns UNIMPLEMENTED.

Parameters
Name Description
name std::string const &

The name of the operation's parent resource.

filter std::string const &

The standard list filter.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< google::longrunning::Operation >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.longrunning.Operation, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

ListOperations(google::longrunning::ListOperationsRequest, Options)

Lists operations that match the specified filter in the request.

If the server doesn't support this method, it returns UNIMPLEMENTED.

Parameters
Name Description
request google::longrunning::ListOperationsRequest

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.longrunning.ListOperationsRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StreamRange< google::longrunning::Operation >

a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.longrunning.Operation, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.

GetOperation(std::string const &, Options)

Gets the latest state of a long-running operation.

Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters
Name Description
name std::string const &

The name of the operation resource.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StatusOr< google::longrunning::Operation >

the result of the RPC. The response message type (google.longrunning.Operation) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

GetOperation(google::longrunning::GetOperationRequest const &, Options)

Gets the latest state of a long-running operation.

Clients can use this method to poll the operation result at intervals as recommended by the API service.

Parameters
Name Description
request google::longrunning::GetOperationRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.longrunning.GetOperationRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
StatusOr< google::longrunning::Operation >

the result of the RPC. The response message type (google.longrunning.Operation) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

CancelOperation(std::string const &, Options)

Starts asynchronous cancellation on a long-running operation.

The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

Parameters
Name Description
name std::string const &

The name of the operation resource to be cancelled.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
Status

a Status object. If the request failed, the status contains the details of the failure.

CancelOperation(google::longrunning::CancelOperationRequest const &, Options)

Starts asynchronous cancellation on a long-running operation.

The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to Code.CANCELLED.

Parameters
Name Description
request google::longrunning::CancelOperationRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.longrunning.CancelOperationRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
Status

a Status object. If the request failed, the status contains the details of the failure.

AsyncWriteLogEntries(std::string const &, google::api::MonitoredResource const &, std::map< std::string, std::string > const &, std::vector< google::logging::v2::LogEntry > const &, Options)

Writes log entries to Logging.

This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)

Parameters
Name Description
log_name std::string const &

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]
  • billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]
  • folders/[FOLDER_ID]/logs/[LOG_ID]
    [LOG_ID] must be URL-encoded. For example:
    "projects/my-project-id/logs/syslog" "organizations/123/logs/cloudaudit.googleapis.com%2Factivity"
    The permission logging.logEntries.create is needed on each project, organization, billing account, or folder that is receiving new log entries, whether the resource is specified in logName or in an individual log entry.
resource google::api::MonitoredResource const &

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.

labels std::map< std::string, std::string > const &

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.

entries std::vector< google::logging::v2::LogEntry > const &

Required. The log entries to send to Logging. The order of log entries in this list does not matter. Values supplied in this method's log_name, resource, and labels fields are copied into those log entries in this list that do not include values for their corresponding fields.
For more information, see WriteLogEntriesRequest.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
future< StatusOr< google::logging::v2::WriteLogEntriesResponse > >

the result of the RPC. The response message type (google.logging.v2.WriteLogEntriesResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.

AsyncWriteLogEntries(google::logging::v2::WriteLogEntriesRequest const &, Options)

Writes log entries to Logging.

This API method is the only way to send log entries to Logging. This method is used, directly or indirectly, by the Logging agent (fluentd) and all logging libraries configured to use Logging. A single request may contain log entries for a maximum of 1000 different resources (projects, organizations, billing accounts or folders)

Parameters
Name Description
request google::logging::v2::WriteLogEntriesRequest const &

Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.logging.v2.WriteLogEntriesRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.

opts Options

Optional. Override the class-level options, such as retry and backoff policies.

Returns
Type Description
future< StatusOr< google::logging::v2::WriteLogEntriesResponse > >

the result of the RPC. The response message type (google.logging.v2.WriteLogEntriesResponse) is mapped to a C++ class using the Protobuf mapping rules. If the request fails, the StatusOr contains the error details.