Documentation ¶
Overview ¶
Package gkelogger is a simple logger that outputs all log entries as single- line JSON objects to stdout. The JSON format is defined by the Google Cloud Logging plugin for fluentd, which is mainly used by The Google Kubernetes Engine + Stackdriver stack. See https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud
Default usage (logging to stderr):
import ( "github.com/TriggerMail/luci-go/common/logging" "github.com/TriggerMail/luci-go/common/logging/gkelogger" ) ... ctx := context.Background() ctx = gkelogger.Use(ctx) logging.Infof(ctx, "Hello %s", "world")
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFactory ¶
GetFactory creates a goroutine safe gkelogger that writes into out.
Types ¶
type LogEntry ¶
type LogEntry struct { // Severity is a string denoting the logging level of the entry. Severity string `json:"severity"` // Message is a single line human readable string of the log message. Message string `json:"message"` // Time is a RFC3389Nano formatted string of the timestamp of the log. Time string `json:"time"` // Fields are extra structured data that may be tagged in the log entry. Fields logging.Fields `json:"fields"` }
LogEntry is created from a single log entry, and is formatted in such a way that the GKE stack expects. The "severity", "message", and "time" fields below are recognized by the Google Cloud Fluentd Plugin. See: https://github.com/GoogleCloudPlatform/fluent-plugin-google-cloud/blob/api_v2/lib/fluent/plugin/out_google_cloud.rb