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

..03-May-2022-

apiv2/H29-Sep-2021-5,5414,060

internal/H29-Sep-2021-646467

logadmin/H29-Sep-2021-2,2281,573

CHANGES.mdH A D29-Sep-20213.4 KiB6634

README.mdH A D29-Sep-20211.1 KiB3930

doc.goH A D29-Sep-20214.1 KiB1361

examples_test.goH A D29-Sep-20215.9 KiB227155

go.modH A D29-Sep-2021475 1815

go.sumH A D29-Sep-202154 KiB552551

go_mod_tidy_hack.goH A D29-Sep-2021937 242

logging.goH A D29-Sep-202130.3 KiB886517

logging_test.goH A D29-Sep-202122.5 KiB840733

logging_unexported_test.goH A D29-Sep-202110 KiB357314

resource.goH A D29-Sep-20217.1 KiB269219

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