Categorygithub.com/joonix/log
modulepackage
0.0.0-20230221083239-7988383bab32
Repository: https://github.com/joonix/log.git
Documentation: pkg.go.dev

# README

Log

GoDoc

Formatter for logrus, allowing log entries to be recognized by the fluentd Stackdriver agent on Google Cloud Platform.

Example:

package main

import (
	"time"
	"net/http"

	log "github.com/sirupsen/logrus"
	joonix "github.com/joonix/log"
)

func main() {
	log.SetFormatter(joonix.NewFormatter())
	log.Info("hello world!")

	// log a HTTP request in your handler
	log.WithField("httpRequest", &joonix.HTTPRequest{
		Request: r,
		Status: http.StatusOK,
		ResponseSize: 31337,
		Latency: 123*time.Millisecond,
	}).Info("additional info")
}

Alternatives

Kubernetes logging from outside of GCP

It is possible to run the google edition of fluentd a.k.a. stackdriver agent outside of GCP, just a bit tricky to configure. See following references for more info:

# Functions

No description provided by the author
NewFormatter with optional options.
No description provided by the author
StackdriverFormat maps values to be recognized by the Google Cloud Platform.

# Variables

DefaultFormat is Stackdriver.

# Structs

Formatter that is called on by logrus.
HTTPRequest contains an http.Request as well as additional information about the request and its response.

# Type aliases

Format configuration of the logrus formatter output.