tree: cab51d8aaaeb9a9594ca4bf2f7ced52a145ec7e2 [path history] [tgz]
  1. .repo-metadata.json
  2. CHANGES.md
  3. README.md
  4. apiv2/
  5. doc.go
  6. examples_test.go
  7. go.mod
  8. go.sum
  9. go_mod_tidy_hack.go
  10. internal/
  11. logadmin/
  12. logging.go
  13. logging_test.go
  14. logging_unexported_test.go
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.
}