Categorygithub.com/kirilldanshin/dlog
modulepackage
0.0.0-20170728000807-97d876b12bf9
Repository: https://github.com/kirilldanshin/dlog.git
Documentation: pkg.go.dev

# README

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"

# Functions

D dumps a value.
F is a build-time disabled printf.
GetCaller is a build-time disabled caller determining.
Ln is a build-time disabled println.
NewBuffered dlog.
P is a build-time disabled print.

# Constants

CallerUnknown returned when caller isn't determined.
State handles dlog state.
StateDisabled is to check if dlog.State disabled.
StateEnabled is to check if dlog.State enabled.

# Structs

Buffered thread-safe dlog.
Caller info.
WithCaller is a dlog with caller info prefix.