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

..11-Nov-2020-

apiv2/H11-Nov-2020-4,5003,270

internal/H11-Nov-2020-646467

logadmin/H11-Nov-2020-2,1521,512

CHANGES.mdH A D11-Nov-20201.2 KiB2716

README.mdH A D11-Nov-20201.1 KiB3930

doc.goH A D11-Nov-20204.1 KiB1361

examples_test.goH A D11-Nov-20205.4 KiB204136

go.modH A D11-Nov-2020506 1815

go.sumH A D11-Nov-202050.1 KiB521520

go_mod_tidy_hack.goH A D11-Nov-2020918 232

logging.goH A D11-Nov-202031.8 KiB957589

logging_test.goH A D11-Nov-202016.8 KiB636530

logging_unexported_test.goH A D11-Nov-202014.1 KiB506458

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