tree: b578d8887cac15d1ad273bb1ccc2a06b167c7dc7 [path history] [tgz]
  1. apiv2/
  2. internal/
  3. logadmin/
  4. doc.go
  5. examples_test.go
  6. logging.go
  7. logging_test.go
  8. logging_unexported_test.go
  9. README.md
logging/README.md

Stackdriver Logging GoDoc

Example Usage

First create a logging.Client to use throughout your application: [snip]:# (logging-1)

ctx := context.Background()
client, err := logging.NewClient(ctx, "my-project")
if err != nil {
	// TODO: Handle error.
}

Usually, you'll want to add log entries to a buffer to be periodically flushed (automatically and asynchronously) to the Stackdriver Logging service. [snip]:# (logging-2)

logger := client.Logger("my-log")
logger.Log(logging.Entry{Payload: "something happened!"})

Close your client before your program exits, to flush any buffered log entries. [snip]:# (logging-3)

err = client.Close()
if err != nil {
	// TODO: Handle error.
}