logging

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

README

Auto-generated logging v2 clients

This package includes auto-generated clients for the logging v2 API.

Use the handwritten logging client (in the parent directory, cloud.google.com/go/logging) in preference to this.

This code is EXPERIMENTAL and subject to CHANGE AT ANY TIME.

Documentation

Overview

Package logging is an auto-generated package for the Stackdriver Logging API.

NOTE: This package is in alpha. It is not stable, and is likely to change.

Writes log entries and manages your Stackdriver Logging configuration.

Use the client at cloud.google.com/go/logging in preference to this.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigExclusionPath deprecated added in v0.16.0

func ConfigExclusionPath(project, exclusion string) string

ConfigExclusionPath returns the path for the exclusion resource.

Deprecated: Use

fmt.Sprintf("projects/%s/exclusions/%s", project, exclusion)

instead.

func ConfigProjectPath deprecated added in v0.7.0

func ConfigProjectPath(project string) string

ConfigProjectPath returns the path for the project resource.

Deprecated: Use

fmt.Sprintf("projects/%s", project)

instead.

func ConfigSinkPath deprecated

func ConfigSinkPath(project, sink string) string

ConfigSinkPath returns the path for the sink resource.

Deprecated: Use

fmt.Sprintf("projects/%s/sinks/%s", project, sink)

instead.

func DefaultAuthScopes added in v0.8.0

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

func LogPath deprecated added in v0.9.0

func LogPath(project, log string) string

LogPath returns the path for the log resource.

Deprecated: Use

fmt.Sprintf("projects/%s/logs/%s", project, log)

instead.

func MetricsMetricPath deprecated

func MetricsMetricPath(project, metric string) string

MetricsMetricPath returns the path for the metric resource.

Deprecated: Use

fmt.Sprintf("projects/%s/metrics/%s", project, metric)

instead.

func MetricsProjectPath deprecated added in v0.7.0

func MetricsProjectPath(project string) string

MetricsProjectPath returns the path for the project resource.

Deprecated: Use

fmt.Sprintf("projects/%s", project)

instead.

func ProjectPath deprecated added in v0.9.0

func ProjectPath(project string) string

ProjectPath returns the path for the project resource.

Deprecated: Use

fmt.Sprintf("projects/%s", project)

instead.

Types

type CallOptions

type CallOptions struct {
	DeleteLog                        []gax.CallOption
	WriteLogEntries                  []gax.CallOption
	ListLogEntries                   []gax.CallOption
	ListMonitoredResourceDescriptors []gax.CallOption
	ListLogs                         []gax.CallOption
}

CallOptions contains the retry settings for each method of Client.

type Client

type Client struct {

	// The call options for this service.
	CallOptions *CallOptions
	// contains filtered or unexported fields
}

Client is a client for interacting with Stackdriver Logging API.

func NewClient

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

NewClient creates a new logging service v2 client.

Service for ingesting and querying logs.

Example
ctx := context.Background()
c, err := logging.NewClient(ctx)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use client.
_ = c
Output:

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*Client) Connection

func (c *Client) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*Client) DeleteLog

func (c *Client) DeleteLog(ctx context.Context, req *loggingpb.DeleteLogRequest, opts ...gax.CallOption) error

DeleteLog deletes all the log entries in a log. The log reappears if it receives new entries. Log entries written shortly before the delete operation might not be deleted.

Example
ctx := context.Background()
c, err := logging.NewClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.DeleteLogRequest{
	// TODO: Fill request struct fields.
}
err = c.DeleteLog(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*Client) ListLogEntries

func (c *Client) ListLogEntries(ctx context.Context, req *loggingpb.ListLogEntriesRequest, opts ...gax.CallOption) *LogEntryIterator

ListLogEntries lists log entries. Use this method to retrieve log entries from Stackdriver Logging. For ways to export log entries, see Exporting Logs (at /logging/docs/export).

Example
ctx := context.Background()
c, err := logging.NewClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.ListLogEntriesRequest{
	// TODO: Fill request struct fields.
}
it := c.ListLogEntries(ctx, req)
for {
	resp, err := it.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) ListLogs added in v0.7.0

func (c *Client) ListLogs(ctx context.Context, req *loggingpb.ListLogsRequest, opts ...gax.CallOption) *StringIterator

ListLogs lists the logs in projects, organizations, folders, or billing accounts. Only logs that have entries are listed.

Example
ctx := context.Background()
c, err := logging.NewClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.ListLogsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListLogs(ctx, req)
for {
	resp, err := it.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) ListMonitoredResourceDescriptors

ListMonitoredResourceDescriptors lists the descriptors for monitored resource types used by Stackdriver Logging.

Example
ctx := context.Background()
c, err := logging.NewClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.ListMonitoredResourceDescriptorsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListMonitoredResourceDescriptors(ctx, req)
for {
	resp, err := it.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*Client) SetGoogleClientInfo

func (c *Client) SetGoogleClientInfo(keyval ...string)

SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.

func (*Client) WriteLogEntries

WriteLogEntries ## Log entry resources

Writes log entries to Stackdriver Logging. This API method is the only way to send log entries to Stackdriver Logging. This method is used, directly or indirectly, by the Stackdriver Logging agent (fluentd) and all logging libraries configured to use Stackdriver Logging.

Example
ctx := context.Background()
c, err := logging.NewClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.WriteLogEntriesRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.WriteLogEntries(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

type ConfigCallOptions

type ConfigCallOptions struct {
	ListSinks       []gax.CallOption
	GetSink         []gax.CallOption
	CreateSink      []gax.CallOption
	UpdateSink      []gax.CallOption
	DeleteSink      []gax.CallOption
	ListExclusions  []gax.CallOption
	GetExclusion    []gax.CallOption
	CreateExclusion []gax.CallOption
	UpdateExclusion []gax.CallOption
	DeleteExclusion []gax.CallOption
}

ConfigCallOptions contains the retry settings for each method of ConfigClient.

type ConfigClient

type ConfigClient struct {

	// The call options for this service.
	CallOptions *ConfigCallOptions
	// contains filtered or unexported fields
}

ConfigClient is a client for interacting with Stackdriver Logging API.

func NewConfigClient

func NewConfigClient(ctx context.Context, opts ...option.ClientOption) (*ConfigClient, error)

NewConfigClient creates a new config service v2 client.

Service for configuring sinks used to export log entries outside of Stackdriver Logging.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use client.
_ = c
Output:

func (*ConfigClient) Close

func (c *ConfigClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*ConfigClient) Connection

func (c *ConfigClient) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*ConfigClient) CreateExclusion added in v0.16.0

CreateExclusion creates a new exclusion in a specified parent resource. Only log entries belonging to that resource can be excluded. You can have up to 10 exclusions in a resource.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.CreateExclusionRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.CreateExclusion(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*ConfigClient) CreateSink

CreateSink creates a sink that exports specified log entries to a destination. The export of newly-ingested log entries begins immediately, unless the sink's writer_identity is not permitted to write to the destination. A sink can export log entries only from the resource owning the sink.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.CreateSinkRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.CreateSink(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*ConfigClient) DeleteExclusion added in v0.16.0

func (c *ConfigClient) DeleteExclusion(ctx context.Context, req *loggingpb.DeleteExclusionRequest, opts ...gax.CallOption) error

DeleteExclusion deletes an exclusion.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.DeleteExclusionRequest{
	// TODO: Fill request struct fields.
}
err = c.DeleteExclusion(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*ConfigClient) DeleteSink

func (c *ConfigClient) DeleteSink(ctx context.Context, req *loggingpb.DeleteSinkRequest, opts ...gax.CallOption) error

DeleteSink deletes a sink. If the sink has a unique writer_identity, then that service account is also deleted.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.DeleteSinkRequest{
	// TODO: Fill request struct fields.
}
err = c.DeleteSink(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*ConfigClient) GetExclusion added in v0.16.0

GetExclusion gets the description of an exclusion.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.GetExclusionRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.GetExclusion(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*ConfigClient) GetSink

GetSink gets a sink.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.GetSinkRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.GetSink(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*ConfigClient) ListExclusions added in v0.16.0

ListExclusions lists all the exclusions in a parent resource.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.ListExclusionsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListExclusions(ctx, req)
for {
	resp, err := it.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*ConfigClient) ListSinks

ListSinks lists sinks.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.ListSinksRequest{
	// TODO: Fill request struct fields.
}
it := c.ListSinks(ctx, req)
for {
	resp, err := it.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*ConfigClient) SetGoogleClientInfo

func (c *ConfigClient) SetGoogleClientInfo(keyval ...string)

SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.

func (*ConfigClient) UpdateExclusion added in v0.16.0

UpdateExclusion changes one or more properties of an existing exclusion.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.UpdateExclusionRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.UpdateExclusion(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*ConfigClient) UpdateSink

UpdateSink updates a sink. This method replaces the following fields in the existing sink with values from the new sink: destination, and filter. The updated sink might also have a new writer_identity; see the unique_writer_identity field.

Example
ctx := context.Background()
c, err := logging.NewConfigClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.UpdateSinkRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.UpdateSink(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

type LogEntryIterator

type LogEntryIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogEntry, nextPageToken string, err error)
	// contains filtered or unexported fields
}

LogEntryIterator manages a stream of *loggingpb.LogEntry.

func (*LogEntryIterator) Next

func (it *LogEntryIterator) Next() (*loggingpb.LogEntry, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*LogEntryIterator) PageInfo added in v0.3.0

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

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type LogExclusionIterator added in v0.16.0

type LogExclusionIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogExclusion, nextPageToken string, err error)
	// contains filtered or unexported fields
}

LogExclusionIterator manages a stream of *loggingpb.LogExclusion.

func (*LogExclusionIterator) Next added in v0.16.0

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*LogExclusionIterator) PageInfo added in v0.16.0

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

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type LogMetricIterator

type LogMetricIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogMetric, nextPageToken string, err error)
	// contains filtered or unexported fields
}

LogMetricIterator manages a stream of *loggingpb.LogMetric.

func (*LogMetricIterator) Next

func (it *LogMetricIterator) Next() (*loggingpb.LogMetric, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*LogMetricIterator) PageInfo added in v0.3.0

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

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type LogSinkIterator

type LogSinkIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*loggingpb.LogSink, nextPageToken string, err error)
	// contains filtered or unexported fields
}

LogSinkIterator manages a stream of *loggingpb.LogSink.

func (*LogSinkIterator) Next

func (it *LogSinkIterator) Next() (*loggingpb.LogSink, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*LogSinkIterator) PageInfo added in v0.3.0

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

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type MetricsCallOptions

type MetricsCallOptions struct {
	ListLogMetrics  []gax.CallOption
	GetLogMetric    []gax.CallOption
	CreateLogMetric []gax.CallOption
	UpdateLogMetric []gax.CallOption
	DeleteLogMetric []gax.CallOption
}

MetricsCallOptions contains the retry settings for each method of MetricsClient.

type MetricsClient

type MetricsClient struct {

	// The call options for this service.
	CallOptions *MetricsCallOptions
	// contains filtered or unexported fields
}

MetricsClient is a client for interacting with Stackdriver Logging API.

func NewMetricsClient

func NewMetricsClient(ctx context.Context, opts ...option.ClientOption) (*MetricsClient, error)

NewMetricsClient creates a new metrics service v2 client.

Service for configuring logs-based metrics.

Example
ctx := context.Background()
c, err := logging.NewMetricsClient(ctx)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use client.
_ = c
Output:

func (*MetricsClient) Close

func (c *MetricsClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*MetricsClient) Connection

func (c *MetricsClient) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*MetricsClient) CreateLogMetric

CreateLogMetric creates a logs-based metric.

Example
ctx := context.Background()
c, err := logging.NewMetricsClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.CreateLogMetricRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.CreateLogMetric(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*MetricsClient) DeleteLogMetric

func (c *MetricsClient) DeleteLogMetric(ctx context.Context, req *loggingpb.DeleteLogMetricRequest, opts ...gax.CallOption) error

DeleteLogMetric deletes a logs-based metric.

Example
ctx := context.Background()
c, err := logging.NewMetricsClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.DeleteLogMetricRequest{
	// TODO: Fill request struct fields.
}
err = c.DeleteLogMetric(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*MetricsClient) GetLogMetric

GetLogMetric gets a logs-based metric.

Example
ctx := context.Background()
c, err := logging.NewMetricsClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.GetLogMetricRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.GetLogMetric(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*MetricsClient) ListLogMetrics

ListLogMetrics lists logs-based metrics.

Example
ctx := context.Background()
c, err := logging.NewMetricsClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.ListLogMetricsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListLogMetrics(ctx, req)
for {
	resp, err := it.Next()
	if err == iterator.Done {
		break
	}
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*MetricsClient) SetGoogleClientInfo

func (c *MetricsClient) SetGoogleClientInfo(keyval ...string)

SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.

func (*MetricsClient) UpdateLogMetric

UpdateLogMetric creates or updates a logs-based metric.

Example
ctx := context.Background()
c, err := logging.NewMetricsClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &loggingpb.UpdateLogMetricRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.UpdateLogMetric(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

type MonitoredResourceDescriptorIterator

type MonitoredResourceDescriptorIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []*monitoredrespb.MonitoredResourceDescriptor, nextPageToken string, err error)
	// contains filtered or unexported fields
}

MonitoredResourceDescriptorIterator manages a stream of *monitoredrespb.MonitoredResourceDescriptor.

func (*MonitoredResourceDescriptorIterator) Next

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*MonitoredResourceDescriptorIterator) PageInfo added in v0.3.0

PageInfo supports pagination. See the google.golang.org/api/iterator package for details.

type StringIterator added in v0.7.0

type StringIterator struct {

	// InternalFetch is for use by the Google Cloud Libraries only.
	// It is not part of the stable interface of this package.
	//
	// InternalFetch returns results from a single call to the underlying RPC.
	// The number of results is no greater than pageSize.
	// If there are no more results, nextPageToken is empty and err is nil.
	InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error)
	// contains filtered or unexported fields
}

StringIterator manages a stream of string.

func (*StringIterator) Next added in v0.7.0

func (it *StringIterator) Next() (string, error)

Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.

func (*StringIterator) PageInfo added in v0.7.0

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

PageInfo supports pagination. See the 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