A logr LogSink implementation using bytes.Buffer

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.

Owner
Tony Li
I love doing lines of code.
Tony Li
Similar Resources

Easily listen to events from multiple contracts using go-ethereum bindings!

eth-log-aggregator Easily listen to events from multiple contracts using go-ethereum bindings! Usage The usage of this tool is exactly the same as abi

Dec 2, 2022

An example logging system using Prometheus, Loki, and Grafana.

An example logging system using Prometheus, Loki, and Grafana.

Logging Example Structure Collector Export numerical data for Prometheus and log data for Promtail. Exporter uses port 8080 Log files are saved to ./c

Nov 21, 2022

A simple re-creation of the first level for Space Invaders using Go and SDL-2.

A simple re-creation of the first level for Space Invaders using Go and SDL-2.

Space Invaders Go Written in Go using SDL2 Usage This application is a sample first level for a re-creation of Space Invaders. The structure of the pr

Feb 27, 2022

Gom: DOM building using Go

gom DOM building using Go Usage package main import "github.com/hadihammurabi/gom" func main() { dom := gom.H("html").Children( gom.H("head").Chi

Dec 16, 2021

Print build info from binary, using buildinfo package.

Go Build Info Print build info from binary, using buildinfo package. https://pkg.go.dev/debug/[email protected] Note: This was created to help me

Dec 30, 2021

Go-bqstreamer - Stream data into Google BigQuery concurrently using InsertAll()

Kik and me (@oryband) are no longer maintaining this repository. Thanks for all the contributions. You are welcome to fork and continue development. B

Dec 7, 2022

A Golang library to manage your environment variables using structs.

genv A simple Golang library to manage your environment variables using structs. How to use package main import ( "github.com/vdgonc/genv" ) type E

Aug 15, 2022

Coletor-mpac - Collector of the Public Ministry of Acre (MPAC) using CDP technology

Ministério Público do Acre(MPAC) Esse coletor é baseado na tecnologia Chrome Dev

Jan 28, 2022

Clean architecture starter pack for faster and easier feature creation using Go.

Clean architecture starter pack for faster and easier feature creation using Go.

cleanarchGo 💫 About Clean architecture starter pack for faster and easier feature creation using Go. This pack includes Clean Architecture with the E

May 8, 2023
Comments
Benchmark - Benchmark of logr implementations

Benchmark of logr implementations Implementations a function (can bridge to non-

Nov 6, 2022
This POC is built with the goal to collect events/logs from the host systems such as Kubernetes, Docker, VMs, etc. A buffering layer is added to buffer events from the collector
This POC is built with the goal to collect events/logs from the host systems such as Kubernetes, Docker, VMs, etc. A buffering layer is added to buffer events from the collector

What is does This POC is build with the goal to collect events/logs from the host systems such as Kubernetes, docker, VMs etc. A buffering layer is ad

Nov 11, 2022
Go implementation of systemd Journal's native API for logging

journald Package journald offers Go implementation of systemd Journal's native API for logging. Key features are: based on a connection-less socket wo

Dec 23, 2022
A Statsd implementation written in GO lang

statsgod Statsgod is a metric aggregation service inspired by the statsd project. Written in Golang, it increases performance and can be deployed with

Oct 1, 2022
A reference implementation of blockchain in Go to demonstrate how blockchain works. For education purpose.
A reference implementation of blockchain in Go to demonstrate how blockchain works. For education purpose.

Mini-Blockchain Mini-Blockchain is a reference design for a blockchain system to demostate a full end2end flow in current blockchain technology. There

Nov 18, 2022
An open source Pusher server implementation compatible with Pusher client libraries written in GO

Try browsing the code on Sourcegraph! IPÊ An open source Pusher server implementation compatible with Pusher client libraries written in Go. Why I wro

Jan 3, 2023
An implementation of A* in Golang

General This is an implementation of the a star path finding algoritm written in Golang. State This software is in pre-alpha state. Development starte

Jan 7, 2022
Gale-Shapley algoritm implementation in Go

Stable matching Gale-Shapley algoritm implementation in Go. Inspired by Numberphile video. See the explanation on Wikipedia Inputs N×N table of propos

Feb 12, 2022
A golang implementation of the Open Pixel Control protocol

__ ___ ___ _____ ___ /'_ `\ / __`\ _______ / __`\/\ '__`\ /'___\ /\ \L\ \/\ \L\ \/\______\/\ \L\ \ \ \L\ \/\ \__/ \ \

Jul 3, 2022
The full power of the Go Compiler directly in your browser, including a virtual file system implementation. Deployable as a static website.
The full power of the Go Compiler directly in your browser, including a virtual file system implementation. Deployable as a static website.

Static Go Playground Features Full Go Compiler running on the browser. Supports using custom build tags. Incremental builds (build cache). Supports mu

Jun 16, 2022