Categorygithub.com/vimeo/grouplogger
modulepackage
0.2.2
Repository: https://github.com/vimeo/grouplogger.git
Documentation: pkg.go.dev

# README

grouplogger

GoDoc

Grouplogger is a specialized Stackdriver logging client for writing groups of log entries. Group entries by contexts that make sense for your application––e.g. by Stackdriver Trace, HTTP request, or Pub/Sub message.

(Stackdriver documentation: Viewing related request log entries)

u, _ := url.Parse("https://api.vimeo.com/")

// Stackdriver requires a non-nil http.Request.
req := &http.Request{
  // Including a trace ID is optional.
  Header: http.Header{
    "X-Cloud-Trace-Context": []string{"your-trace-id"},
  },
  // Stackdriver requires the http.Request to have a URL.
  URL: u,
}

ctx := context.Background()
cli, _ := grouplogger.NewClient(ctx, "your-project-id")

logger := cli.Logger(req, "logname")

logger.Info("Entry with Info severity.")
logger.Notice(map[string][]string{
  "Words": []string{"structured", "data", "in", "entries"},
})
logger.Warning("Look out! Entry with Warning severity.")

logger.Close()

_ = cli.Close()
screen shot 2018-07-31 at 12 33 06 pm

# Functions

NewClient generates a new Client associated with the provided parent.
WithHostname adds the hostname to a labels map.

# Structs

Client adds different Logger generation to Stackdriver's logging.Client.
GroupLogger wraps two Stackdriver Logger clients.