Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 913 Bytes

README.md

File metadata and controls

36 lines (25 loc) · 913 Bytes

buflogr

Go Reference

Go Report Card

A logr LogSink implementation using bytes.Buffer.

Usage

import (
	"bytes"
	"fmt"

	"github.com/go-logr/logr"
	"github.com/tonglil/buflogr"
)

func main() {
	var buf bytes.Buffer
	var log logr.Logger = buflogr.NewWithBuffer(&buf)

	log = log.WithName("my app")
	log = log.WithValues("format", "none")

	log.Info("Logr in action!", "the answer", 42)

	fmt.Print(buf.String())
}

Implementation Details

This is a simple log adapter to log messages into a buffer. Useful for testing.