Categorygithub.com/chinaran/debuglog
repositorypackage
0.0.0-20210624004517-e267b4bd3f4e
Repository: https://github.com/chinaran/debuglog.git
Documentation: pkg.go.dev

# README

debuglog

Easy log variable for debugging

Usage

go get -u github.com/chinaran/debuglog

Functions

debuglog.Val()

print a value

debuglog.SpewVal()

print a value using spew https://github.com/davecgh/go-spew

debuglog.ToJson()

print a value (json string)

debuglog.ToJsonPretty()

print a value (pretty json string)

Example

package main

import "github.com/chinaran/debuglog"

type TestJson struct {
	Id   int64
	Name string
}

func main() {
	intVal := 123
	debuglog.Val(intVal)
	debuglog.Val(intVal, "prefix1")
	debuglog.Val(intVal, "prefix1", "prefix2")

	testJson := TestJson{Id: 987, Name: "alan"}

	debuglog.SpewVal(testJson, "testJson Spew")
	// debuglog.OctUtf8Val(testJson, "testJson")

	debuglog.ToJson(testJson, "testJson")
	debuglog.ToJsonPretty(testJson, "testJson Pretty")
}

result:

result