Skip to content

justDMNK/logrus-stackdriver-formatter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logrus Stackdriver Formatter

Formatter for logrus which uses gofiber for the httpRequest instead of the default net/http Request, allowing log entries to be recognized by the fluentd Stackdriver agent on Google Cloud Platform.

Example:

package main

import (
	"github.com/gofiber/fiber/v2"
	log "github.com/sirupsen/logrus"
	logForm "github.com/justDMNK/logrus-stackdriver-formatter"
	"time"
)

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

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

Original

About

Logging utilities

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%