~gioverse/chat

c86e075f0df33cc01ac99f167a09f981997727d0 — Chris Waldon 4 months ago f3d6c43
debug: add function to easily log structures

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 11 insertions(+), 0 deletions(-)

M debug/debug.go
M debug/debug.go => debug/debug.go +11 -0
@@ 4,7 4,11 @@ Package debug provides tools for debugging Gio layout code.
package debug

import (
	"bytes"
	"encoding/json"
	"image/color"
	"io"
	"os"

	"gioui.org/layout"
	"gioui.org/unit"


@@ 23,3 27,10 @@ func Outline(gtx C, w func(gtx C) D) D {
		Width: unit.Dp(1),
	}.Layout(gtx, w)
}

// Dump logs the input as formatting JSON on stderr.
func Dump(v interface{}) {
	b, _ := json.MarshalIndent(v, "", "  ")
	b = append(b, []byte("\n")...)
	io.Copy(os.Stderr, bytes.NewBuffer(b))
}