• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Jun-2020-

apiv2/H18-Jun-2020-4,3673,150

internal/H18-Jun-2020-646467

logadmin/H18-Jun-2020-2,1531,513

CHANGES.mdH A D18-Jun-2020191 64

README.mdH A D18-Jun-20201.1 KiB3530

doc.goH A D18-Jun-20204.1 KiB1351

examples_test.goH A D18-Jun-20205 KiB184120

go.modH A D18-Jun-2020684 2118

go.sumH A D18-Jun-202045.9 KiB477476

go_mod_tidy_hack.goH A D18-Jun-2020918 232

logging.goH A D18-Jun-202031.4 KiB954591

logging_test.goH A D18-Jun-202017.3 KiB647537

logging_unexported_test.goH A D18-Jun-202013 KiB458412

README.md

1## Stackdriver Logging [![GoDoc](https://godoc.org/cloud.google.com/go/logging?status.svg)](https://godoc.org/cloud.google.com/go/logging)
2
3- [About Stackdriver Logging](https://cloud.google.com/logging/)
4- [API documentation](https://cloud.google.com/logging/docs)
5- [Go client documentation](https://godoc.org/cloud.google.com/go/logging)
6- [Complete sample programs](https://github.com/GoogleCloudPlatform/golang-samples/tree/master/logging)
7
8### Example Usage
9
10First create a `logging.Client` to use throughout your application:
11[snip]:# (logging-1)
12```go
13ctx := context.Background()
14client, err := logging.NewClient(ctx, "my-project")
15if err != nil {
16	// TODO: Handle error.
17}
18```
19
20Usually, you'll want to add log entries to a buffer to be periodically flushed
21(automatically and asynchronously) to the Stackdriver Logging service.
22[snip]:# (logging-2)
23```go
24logger := client.Logger("my-log")
25logger.Log(logging.Entry{Payload: "something happened!"})
26```
27
28Close your client before your program exits, to flush any buffered log entries.
29[snip]:# (logging-3)
30```go
31err = client.Close()
32if err != nil {
33	// TODO: Handle error.
34}
35```