Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
apiv2/ | H | 11-Oct-2019 | - | 3,622 | 2,653 | |
internal/ | H | 11-Oct-2019 | - | 646 | 467 | |
logadmin/ | H | 11-Oct-2019 | - | 2,136 | 1,499 | |
.repo-metadata.json | H A D | 11-Oct-2019 | 407 | 13 | 12 | |
CHANGES.md | H A D | 11-Oct-2019 | 191 | 6 | 4 | |
README.md | H A D | 11-Oct-2019 | 1.1 KiB | 35 | 30 | |
doc.go | H A D | 11-Oct-2019 | 4.1 KiB | 135 | 1 | |
examples_test.go | H A D | 11-Oct-2019 | 5 KiB | 184 | 120 | |
go.mod | H A D | 11-Oct-2019 | 569 | 19 | 16 | |
go.sum | H A D | 11-Oct-2019 | 16.2 KiB | 169 | 168 | |
go_mod_tidy_hack.go | H A D | 11-Oct-2019 | 918 | 23 | 2 | |
logging.go | H A D | 11-Oct-2019 | 31.2 KiB | 944 | 583 | |
logging_test.go | H A D | 11-Oct-2019 | 16.8 KiB | 632 | 524 | |
logging_unexported_test.go | H A D | 11-Oct-2019 | 13 KiB | 458 | 412 |
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```