Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 11-Nov-2020 | - | ||||
apiv2/ | H | 11-Nov-2020 | - | 4,500 | 3,270 | |
internal/ | H | 11-Nov-2020 | - | 646 | 467 | |
logadmin/ | H | 11-Nov-2020 | - | 2,152 | 1,512 | |
CHANGES.md | H A D | 11-Nov-2020 | 1.2 KiB | 27 | 16 | |
README.md | H A D | 11-Nov-2020 | 1.1 KiB | 39 | 30 | |
doc.go | H A D | 11-Nov-2020 | 4.1 KiB | 136 | 1 | |
examples_test.go | H A D | 11-Nov-2020 | 5.4 KiB | 204 | 136 | |
go.mod | H A D | 11-Nov-2020 | 506 | 18 | 15 | |
go.sum | H A D | 11-Nov-2020 | 50.1 KiB | 521 | 520 | |
go_mod_tidy_hack.go | H A D | 11-Nov-2020 | 918 | 23 | 2 | |
logging.go | H A D | 11-Nov-2020 | 31.8 KiB | 957 | 589 | |
logging_test.go | H A D | 11-Nov-2020 | 16.8 KiB | 636 | 530 | |
logging_unexported_test.go | H A D | 11-Nov-2020 | 14.1 KiB | 506 | 458 |
README.md
1## Cloud Logging [![GoDoc](https://godoc.org/cloud.google.com/go/logging?status.svg)](https://godoc.org/cloud.google.com/go/logging) 2 3- [About Cloud Logging](https://cloud.google.com/logging/) 4- [API documentation](https://cloud.google.com/logging/docs) 5- [Go client documentation](https://pkg.go.dev/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 13```go 14ctx := context.Background() 15client, err := logging.NewClient(ctx, "my-project") 16if err != nil { 17 // TODO: Handle error. 18} 19``` 20 21Usually, you'll want to add log entries to a buffer to be periodically flushed 22(automatically and asynchronously) to the Cloud Logging service. 23[snip]:# (logging-2) 24 25```go 26logger := client.Logger("my-log") 27logger.Log(logging.Entry{Payload: "something happened!"}) 28``` 29 30Close your client before your program exits, to flush any buffered log entries. 31[snip]:# (logging-3) 32 33```go 34err = client.Close() 35if err != nil { 36 // TODO: Handle error. 37} 38``` 39