Skip to content

A logr LogSink implementation using bytes.Buffer

License

Notifications You must be signed in to change notification settings

tonglil/buflogr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A logr LogSink implementation using bytes.Buffer

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages