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

..03-May-2022-

apiv2/H11-Oct-2019-3,6222,653

internal/H11-Oct-2019-646467

logadmin/H11-Oct-2019-2,1361,499

.repo-metadata.jsonH A D11-Oct-2019407 1312

CHANGES.mdH A D11-Oct-2019191 64

README.mdH A D11-Oct-20191.1 KiB3530

doc.goH A D11-Oct-20194.1 KiB1351

examples_test.goH A D11-Oct-20195 KiB184120

go.modH A D11-Oct-2019569 1916

go.sumH A D11-Oct-201916.2 KiB169168

go_mod_tidy_hack.goH A D11-Oct-2019918 232

logging.goH A D11-Oct-201931.2 KiB944583

logging_test.goH A D11-Oct-201916.8 KiB632524

logging_unexported_test.goH A D11-Oct-201913 KiB458412

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```