Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | 03-May-2022 | - | ||||
apiv2/ | H | 29-Sep-2021 | - | 5,541 | 4,060 | |
internal/ | H | 29-Sep-2021 | - | 646 | 467 | |
logadmin/ | H | 29-Sep-2021 | - | 2,228 | 1,573 | |
CHANGES.md | H A D | 29-Sep-2021 | 3.4 KiB | 66 | 34 | |
README.md | H A D | 29-Sep-2021 | 1.1 KiB | 39 | 30 | |
doc.go | H A D | 29-Sep-2021 | 4.1 KiB | 136 | 1 | |
examples_test.go | H A D | 29-Sep-2021 | 5.9 KiB | 227 | 155 | |
go.mod | H A D | 29-Sep-2021 | 475 | 18 | 15 | |
go.sum | H A D | 29-Sep-2021 | 54 KiB | 552 | 551 | |
go_mod_tidy_hack.go | H A D | 29-Sep-2021 | 937 | 24 | 2 | |
logging.go | H A D | 29-Sep-2021 | 30.3 KiB | 886 | 517 | |
logging_test.go | H A D | 29-Sep-2021 | 22.5 KiB | 840 | 733 | |
logging_unexported_test.go | H A D | 29-Sep-2021 | 10 KiB | 357 | 314 | |
resource.go | H A D | 29-Sep-2021 | 7.1 KiB | 269 | 219 |
README.md
1## Cloud Logging [![Go Reference](https://pkg.go.dev/badge/cloud.google.com/go/logging.svg)](https://pkg.go.dev/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