luci: Index | Files

package gkelogger

import ""

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

Default usage (logging to stderr):

import (


ctx := context.Background()
ctx = gkelogger.Use(ctx)
logging.Infof(ctx, "Hello %s", "world")


Package Files

config.go doc.go logger.go

func GetFactory Uses

func GetFactory(out io.Writer) func(context.Context) logging.Logger

GetFactory creates a goroutine safe gkelogger that writes into out.

func Use Uses

func Use(c context.Context, out io.Writer) context.Context

Use registers a JSON based logger as default logger of the context that emits line to out.

type LogEntry Uses

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:

Package gkelogger imports 8 packages (graph) and is imported by 2 packages. Updated 2019-04-24. Refresh now. Tools for package owners.