def list_entries( self, *, resource_names=None, filter_=None, order_by=None, max_results=None, page_size=None, page_token=None, ): """Return a generator of log entry resources. Args: resource_names (Sequence[str]): 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]" If not passed, defaults to the project bound to the API's client. filter_ (str): a filter expression. See https://cloud.google.com/logging/docs/view/advanced_filters order_by (str) One of :data:`~logging_v2.ASCENDING` or :data:`~logging_v2.DESCENDING`. max_results (Optional[int]): Optional. The maximum number of entries to return. Non-positive values are treated as 0. If None, uses API defaults. page_size (int): number of entries to fetch in each API call. Although requests are paged internally, logs are returned by the generator one at a time. If not passed, defaults to a value set by the API. page_token (str): opaque marker for the starting "page" of entries. If not passed, the API will return the first page of entries. Returns: Generator[~logging_v2.LogEntry] """ if resource_names is None: resource_names = [f"projects/{self.project}"] filter_ = _add_defaults_to_filter(filter_) return self.logging_api.list_entries( resource_names=resource_names, filter_=filter_, order_by=order_by, max_results=max_results, page_size=page_size, page_token=page_token, )
def list_entries( self, *, resource_names=None, filter_=None, order_by=None, page_size=None, page_token=None, ): """Return a page of log entry resources. Args: resource_names (Sequence[str]): 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]" If not passed, defaults to the project bound to the API's client. filter_ (str): a filter expression. See https://cloud.google.com/logging/docs/view/advanced_filters order_by (str) One of :data:`~logging_v2.ASCENDING` or :data:`~logging_v2.DESCENDING`. page_size (int): maximum number of entries to return, If not passed, defaults to a value set by the API. page_token (str): opaque marker for the next "page" of entries. If not passed, the API will return the first page of entries. Returns: Iterator[~logging_v2.LogEntry] """ if resource_names is None: resource_names = [f"projects/{self.project}"] filter_ = _add_defaults_to_filter(filter_) return self.logging_api.list_entries( resource_names=resource_names, filter_=filter_, order_by=order_by, page_size=page_size, page_token=page_token, )
def list_entries( self, *, resource_names=None, filter_=None, order_by=None, page_size=None, page_token=None, ): """Return a page of log entries. See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list Args: resource_names (Optional[Sequence[str]]): 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]" If not passed, defaults to the project bound to the client. filter_ (Optional[str]): a filter expression. See https://cloud.google.com/logging/docs/view/advanced_filters By default, a 24 hour filter is applied. order_by (Optional[str]): One of :data:`~logging_v2.ASCENDING` or :data:`~logging_v2.DESCENDING`. page_size (Optional[int]): Optional. The maximum number of entries in each page of results from this request. Non-positive values are ignored. Defaults to a sensible value set by the API. page_token (Optional[str]): Optional. If present, return the next batch of entries, using the value, which must correspond to the ``nextPageToken`` value returned in the previous response. Deprecated: use the ``pages`` property of the returned iterator instead of manually passing the token. Returns: Iterator[~logging_v2.entries.LogEntry] """ if resource_names is None: resource_names = [f"projects/{self.project}"] log_filter = f"logName={self.full_name}" if filter_ is not None: filter_ = f"{filter_} AND {log_filter}" else: filter_ = log_filter filter_ = _add_defaults_to_filter(filter_) return self.client.list_entries( resource_names=resource_names, filter_=filter_, order_by=order_by, page_size=page_size, page_token=page_token, )
def _add_defaults_to_filter(filter_): from google.cloud.logging_v2._helpers import _add_defaults_to_filter return _add_defaults_to_filter(filter_)