logadmin

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2025 License: MIT Imports: 11 Imported by: 0

README

logadmin

This folder contains a trimmed and edited copy of cloud.google.com/go/logging/logadmin.

The changes enable us to directly iterate over loggingpb.LogEntry instead of logging.Entry. This adjustment ensures that log entries are serialized to match the output format of gcloud logging read.

Documentation

Overview

Package logadmin contains a Cloud Logging client that can be used for reading logs and working with sinks, metrics and monitored resources. For a client that can write logs, see package cloud.google.com/go/logging.

The client uses Logging API v2. See https://cloud.google.com/logging/docs/api/v2/ for an introduction to the API.

Note: This package is in beta. Some backwards-incompatible changes may occur.

Index

Constants

View Source
const Version = "1.13.0"

Version is the current tagged release of the library.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a Logging client. A Client is associated with a single Cloud project.

func NewClient

func NewClient(ctx context.Context, parent string, opts ...option.ClientOption) (*Client, error)

NewClient returns a new logging client associated with the provided project ID.

By default NewClient uses AdminScope. To use a different scope, call NewClient using a WithScopes option (see https://godoc.org/google.golang.org/api/option#WithScopes).

func (*Client) Close

func (c *Client) Close() error

Close closes the client.

func (*Client) Entries

func (c *Client) Entries(ctx context.Context, opts ...EntriesOption) *EntryIterator

Entries returns an EntryIterator for iterating over log entries. By default, the log entries will be restricted to those from the project passed to NewClient. This may be overridden by passing a ProjectIDs option. Requires ReadScope or AdminScope.

type EntriesOption

type EntriesOption interface {
	// contains filtered or unexported methods
}

An EntriesOption is an option for listing log entries.

func Filter

func Filter(f string) EntriesOption

Filter sets an advanced logs filter for listing log entries (see https://cloud.google.com/logging/docs/view/advanced_filters). The filter is compared against all log entries in the projects specified by ProjectIDs. Only entries that match the filter are retrieved. An empty filter (the default) matches all log entries.

In the filter string, log names must be written in their full form, as "projects/PROJECT-ID/logs/LOG-ID". Forward slashes in LOG-ID must be replaced by %2F before calling Filter.

Timestamps in the filter string must be written in RFC 3339 format. By default, timestamp filters for the past 24 hours.

func NewestFirst

func NewestFirst() EntriesOption

NewestFirst causes log entries to be listed from most recent (newest) to least recent (oldest). By default, they are listed from oldest to newest.

func PageSize

func PageSize(p int32) EntriesOption

PageSize provide a way to override number of results to return from each request.

func ProjectIDs

func ProjectIDs(pids []string) EntriesOption

ProjectIDs sets the project IDs or project numbers from which to retrieve log entries. Examples of a project ID: "my-project-1A", "1234567890".

func ResourceNames

func ResourceNames(rns []string) EntriesOption

ResourceNames sets the resource names from which to retrieve log entries. Examples: "projects/my-project-1A", "organizations/my-org".

type EntryIterator

type EntryIterator struct {
	// contains filtered or unexported fields
}

An EntryIterator iterates over log entries.

func (*EntryIterator) Next

func (it *EntryIterator) Next() (*logpb.LogEntry, error)

Next returns the next result. Its second return value is iterator.Done (https://godoc.org/google.golang.org/api/iterator) if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*EntryIterator) PageInfo

func (it *EntryIterator) PageInfo() *iterator.PageInfo

PageInfo supports pagination. See https://godoc.org/google.golang.org/api/iterator package for details.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL