Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 1.23 KB

README.md

File metadata and controls

48 lines (33 loc) · 1.23 KB

go-debug

GoDoc

debugger provides an environment based debugger in code.

Based heavily on visionmedia's debug.

Install

$ go get github.com/swhite24/go-debug

Usage

debugger will output logs based on the DEBUG environment variable. DEBUG may be comma-separated to provide multiple values, each of which may contain a wildcard *. If the provided key does not contain a match in the environment, no output will be displayed.

For instance, the following script:

package main

import (
	"time"
    "github.com/swhite24/go-debug"
)

func main () {
    hello := debugger.NewDebugger("hello")
    world := debugger.NewDebugger("world")
    foo := debugger.NewDebugger("foo")

    hello.Log("Log from hello")
    world.Log("Log from world")
    foo.Log("Log from foo")

	time.Sleep(time.Duration(1) * time.Second)
	hello.Log("Log from hello after 1 sec")
}

when run with the command DEBUG=hel*,world go run test.go will output the following:

Note the use of wildcards and the omission of logs from the "foo" debugger.