Documentation ¶
Overview ¶
Service for ingesting and querying logs.
Package logging is an experimental, auto-generated package for the logging API.
The Google Cloud Logging API lets you write log entries and manage your logs, log sinks and logs-based metrics.
Index ¶
- Variables
- func LogPath(project string, log string) string
- func ProjectPath(project string) string
- type Client
- func (c *Client) Close() error
- func (c *Client) DeleteLog(ctx context.Context, req *google_logging_v2.DeleteLogRequest) error
- func (c *Client) ListLogEntries(ctx context.Context, req *google_logging_v2.ListLogEntriesRequest) *LogEntryIterator
- func (c *Client) ListMonitoredResourceDescriptors(ctx context.Context, ...) *MonitoredResourceDescriptorIterator
- func (c *Client) WriteLogEntries(ctx context.Context, req *google_logging_v2.WriteLogEntriesRequest) (*google_logging_v2.WriteLogEntriesResponse, error)
- type LogEntryIterator
- func (it *LogEntryIterator) Next() (*google_logging_v2.LogEntry, error)
- func (it *LogEntryIterator) NextPage() ([]*google_logging_v2.LogEntry, error)
- func (it *LogEntryIterator) NextPageToken() string
- func (it *LogEntryIterator) SetPageSize(pageSize int32)
- func (it *LogEntryIterator) SetPageToken(token string)
- type MonitoredResourceDescriptorIterator
- func (it *MonitoredResourceDescriptorIterator) Next() (*google_api.MonitoredResourceDescriptor, error)
- func (it *MonitoredResourceDescriptorIterator) NextPage() ([]*google_api.MonitoredResourceDescriptor, error)
- func (it *MonitoredResourceDescriptorIterator) NextPageToken() string
- func (it *MonitoredResourceDescriptorIterator) SetPageSize(pageSize int32)
- func (it *MonitoredResourceDescriptorIterator) SetPageToken(token string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Done is returned by iterators on successful completion. Done = errors.New("iterator done") )
Functions ¶
func ProjectPath ¶
ProjectPath returns the path for the project resource.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for interacting with LoggingServiceV2.
func NewClient ¶
NewClient creates a new API service client.
Example ¶
package main import ( "cloud.google.com/go/logging/apiv2/logging" gax "github.com/googleapis/gax-go" "golang.org/x/net/context" ) func main() { ctx := context.Background() opts := []gax.ClientOption{ /* Optional client parameters. */ } c, err := logging.NewClient(ctx, opts...) _, _ = c, err // Handle error. }
Output:
func (*Client) Close ¶
Close closes the connection to the API service. The user should invoke this when the client is no longer required.
func (*Client) DeleteLog ¶
func (c *Client) DeleteLog(ctx context.Context, req *google_logging_v2.DeleteLogRequest) error
DeleteLog deletes a log and all its log entries. The log will reappear if it receives new entries.
Example ¶
package main import ( "cloud.google.com/go/logging/apiv2/logging" google_logging_v2 "github.com/googleapis/proto-client-go/logging/v2" "golang.org/x/net/context" ) func main() { ctx := context.Background() c, err := logging.NewClient(ctx) _ = err // Handle error. req := &google_logging_v2.DeleteLogRequest{ /* Data... */ } err = c.DeleteLog(ctx, req) _ = err // Handle error. }
Output:
func (*Client) ListLogEntries ¶
func (c *Client) ListLogEntries(ctx context.Context, req *google_logging_v2.ListLogEntriesRequest) *LogEntryIterator
ListLogEntries lists log entries. Use this method to retrieve log entries from Cloud Logging. For ways to export log entries, see [Exporting Logs](/logging/docs/export).
Example ¶
package main import ( "cloud.google.com/go/logging/apiv2/logging" google_logging_v2 "github.com/googleapis/proto-client-go/logging/v2" "golang.org/x/net/context" ) func main() { ctx := context.Background() c, err := logging.NewClient(ctx) _ = err // Handle error. req := &google_logging_v2.ListLogEntriesRequest{ /* Data... */ } it := c.ListLogEntries(ctx, req) var resp *google_logging_v2.LogEntry for { resp, err = it.Next() if err != nil { break } } _ = resp }
Output:
func (*Client) ListMonitoredResourceDescriptors ¶
func (c *Client) ListMonitoredResourceDescriptors(ctx context.Context, req *google_logging_v2.ListMonitoredResourceDescriptorsRequest) *MonitoredResourceDescriptorIterator
ListMonitoredResourceDescriptors lists monitored resource descriptors that are used by Cloud Logging.
Example ¶
package main import ( "cloud.google.com/go/logging/apiv2/logging" google_api "github.com/googleapis/proto-client-go/api" google_logging_v2 "github.com/googleapis/proto-client-go/logging/v2" "golang.org/x/net/context" ) func main() { ctx := context.Background() c, err := logging.NewClient(ctx) _ = err // Handle error. req := &google_logging_v2.ListMonitoredResourceDescriptorsRequest{ /* Data... */ } it := c.ListMonitoredResourceDescriptors(ctx, req) var resp *google_api.MonitoredResourceDescriptor for { resp, err = it.Next() if err != nil { break } } _ = resp }
Output:
func (*Client) WriteLogEntries ¶
func (c *Client) WriteLogEntries(ctx context.Context, req *google_logging_v2.WriteLogEntriesRequest) (*google_logging_v2.WriteLogEntriesResponse, error)
WriteLogEntries writes log entries to Cloud Logging. All log entries in Cloud Logging are written by this method.
Example ¶
package main import ( "cloud.google.com/go/logging/apiv2/logging" google_logging_v2 "github.com/googleapis/proto-client-go/logging/v2" "golang.org/x/net/context" ) func main() { ctx := context.Background() c, err := logging.NewClient(ctx) _ = err // Handle error. req := &google_logging_v2.WriteLogEntriesRequest{ /* Data... */ } var resp *google_logging_v2.WriteLogEntriesResponse resp, err = c.WriteLogEntries(ctx, req) _, _ = resp, err // Handle error. }
Output:
type LogEntryIterator ¶
type LogEntryIterator struct {
// contains filtered or unexported fields
}
LogEntryIterator manages a stream of *google_logging_v2.LogEntry.
func (*LogEntryIterator) Next ¶
func (it *LogEntryIterator) Next() (*google_logging_v2.LogEntry, error)
Next returns the next element in the stream. It returns Done at the end of the stream.
func (*LogEntryIterator) NextPage ¶
func (it *LogEntryIterator) NextPage() ([]*google_logging_v2.LogEntry, error)
NextPage moves to the next page and updates its internal data. It returns Done if no more pages exist.
func (*LogEntryIterator) NextPageToken ¶
func (it *LogEntryIterator) NextPageToken() string
NextPageToken returns the next page token.
func (*LogEntryIterator) SetPageSize ¶
func (it *LogEntryIterator) SetPageSize(pageSize int32)
SetPageSize sets the maximum size of the next page to be retrieved.
func (*LogEntryIterator) SetPageToken ¶
func (it *LogEntryIterator) SetPageToken(token string)
SetPageToken sets the next page token to be retrieved. Note, it does not retrieve the next page, or modify the cached page. If Next is called, there is no guarantee that the result returned will be from the next page until NextPage is called.
type MonitoredResourceDescriptorIterator ¶
type MonitoredResourceDescriptorIterator struct {
// contains filtered or unexported fields
}
MonitoredResourceDescriptorIterator manages a stream of *google_api.MonitoredResourceDescriptor.
func (*MonitoredResourceDescriptorIterator) Next ¶
func (it *MonitoredResourceDescriptorIterator) Next() (*google_api.MonitoredResourceDescriptor, error)
Next returns the next element in the stream. It returns Done at the end of the stream.
func (*MonitoredResourceDescriptorIterator) NextPage ¶
func (it *MonitoredResourceDescriptorIterator) NextPage() ([]*google_api.MonitoredResourceDescriptor, error)
NextPage moves to the next page and updates its internal data. It returns Done if no more pages exist.
func (*MonitoredResourceDescriptorIterator) NextPageToken ¶
func (it *MonitoredResourceDescriptorIterator) NextPageToken() string
NextPageToken returns the next page token.
func (*MonitoredResourceDescriptorIterator) SetPageSize ¶
func (it *MonitoredResourceDescriptorIterator) SetPageSize(pageSize int32)
SetPageSize sets the maximum size of the next page to be retrieved.
func (*MonitoredResourceDescriptorIterator) SetPageToken ¶
func (it *MonitoredResourceDescriptorIterator) SetPageToken(token string)
SetPageToken sets the next page token to be retrieved. Note, it does not retrieve the next page, or modify the cached page. If Next is called, there is no guarantee that the result returned will be from the next page until NextPage is called.