Skip to content

Simple build-time controlled debug log with ability to log where the logger was called

License

Notifications You must be signed in to change notification settings

kirillDanshin/dlog

Repository files navigation

dlog GoDoc Go Report Card

Simple build-time controlled debug log

How to use

Unbuffered

package main

import "github.com/kirillDanshin/dlog"

func main() {
	a := []int{2, 4, 8, 16, 32, 64, 128, 256, 512}
	b := "some string"
	
	dlog.D(a)		// D'ump `a`
	dlog.P(b)		// P'rint `b`
	dlog.F("%s format", b)	// F'ormatted print
	dlog.Ln(b)		// print'Ln `b`
}

Buffered

package main

import "github.com/kirillDanshin/dlog"

func main() {
	log := dlog.NewBuffered()
	defer log.Release()
	
	log.D(a)		// D'ump `a`
	log.P(b)		// P'rint `b`
	log.F("%s format", b)	// F'ormatted print
	log.Ln(b)		// print'Ln `b`

	dlog.Ln(log) // or fmt.Println("log") etc.
}

Release

To disable logging in release build just run

	go build

Debug

To enable logging in debug build run

	go build -tags "debug"

About

Simple build-time controlled debug log with ability to log where the logger was called

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages