Skip to content

swhite24/go-debug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Environment based debugger for golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages