Documentation ¶
Overview ¶
Package dbg shows more or less output using different debug-levels. You can use
dbg.Lvl1("Important information") dbg.Lvl2("Less important information") dbg.Lvl3("Eventually flooding information") dbg.Lvl4("Definitively flooding information") dbg.Lvl5("I hope you never need this")
in your program, then according to the debug-level one or more levels of output will be shown. To set the debug-level, use
dbg.SetDebugVisible(3)
which will show all `Lvl1`, `Lvl2`, and `Lvl3`. If you want to turn on just one output, you can use
dbg.LLvl2("Less important information")
By adding a single 'L' to the method, it *always* gets printed.
You can also add a 'f' to the name and use it like fmt.Printf:
dbg.Lvlf1("Level: %d/%d", now, max)
Additional to that you also have
dbg.Warn("Only a warning") dbg.Error("This is an error, but continues") dbg.Panic("Something really went bad - calls panic") dbg.Fatal("No way to continue - calls os.Exit")
The dbg-package also takes into account the following environment-variables:
DEBUG_LVL // will act like SetDebugVisible DEBUG_TIME // if 'true' it will print the date and time DEBUG_COLOR // if 'false' it will not use colors
But for this the function ParseEnv() or AddFlags() has to be called.
Index ¶
- Variables
- func AddFlags()
- func AfterTest(t *testing.T)
- func DebugVisible() int
- func ErrFatal(err error, msg ...string)
- func Error(args ...interface{})
- func Errorf(f string, args ...interface{})
- func Fatal(args ...interface{})
- func Fatalf(f string, args ...interface{})
- func LLvl1(args ...interface{})
- func LLvl2(args ...interface{})
- func LLvl3(args ...interface{})
- func LLvl4(args ...interface{})
- func LLvl5(args ...interface{})
- func LLvlf1(f string, args ...interface{})
- func LLvlf2(f string, args ...interface{})
- func LLvlf3(f string, args ...interface{})
- func LLvlf4(f string, args ...interface{})
- func LLvlf5(f string, args ...interface{})
- func Lvl1(args ...interface{})
- func Lvl2(args ...interface{})
- func Lvl3(args ...interface{})
- func Lvl4(args ...interface{})
- func Lvl5(args ...interface{})
- func Lvlf1(f string, args ...interface{})
- func Lvlf2(f string, args ...interface{})
- func Lvlf3(f string, args ...interface{})
- func Lvlf4(f string, args ...interface{})
- func Lvlf5(f string, args ...interface{})
- func MainTest(m *testing.M)
- func Panic(args ...interface{})
- func Panicf(f string, args ...interface{})
- func ParseEnv()
- func Print(args ...interface{})
- func Printf(f string, args ...interface{})
- func SetDebugVisible(lvl int)
- func SetShowTime(show bool)
- func SetUseColors(show bool)
- func ShowTime() bool
- func Stack() string
- func TestFatal(t *testing.T, err error, msg ...string)
- func TestOutput(show bool, level int)
- func UseColors() bool
- func Warn(args ...interface{})
- func Warnf(f string, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var LinePadding = 3
LinePadding of line-numbers for a nice debug-output - used in the same way as NamePadding
var NamePadding = 40
NamePadding - the padding of functions to make a nice debug-output - this is automatically updated whenever there are longer functions and kept at that new maximum. If you prefer to have a fixed output and don't remember oversized names, put a negative value in here
var StaticMsg = ""
StaticMsg - if this variable is set, it will be outputted between the position and the message
var TestStr = ""
TestStr is only used in testing to redirect output to this string
var Testing = 0
Testing variable can have multiple values 0 - no testing 1 - put all line-numbers to 0 2 - like 1, but write to TestString instead of stdout
Functions ¶
func AfterTest ¶
AfterTest can be called to wait for leaking goroutines to finish. If they do not finish after a reasonable time (600ms) the test will fail.
Inspired by https://golang.org/src/net/http/main_test.go and https://github.com/coreos/etcd/blob/master/pkg/testutil/leak.go
func Errorf ¶
func Errorf(f string, args ...interface{})
Errorf is like Error but with a format-string
func Fatalf ¶
func Fatalf(f string, args ...interface{})
Fatalf is like Fatal but with a format-string
func Lvl2 ¶
func Lvl2(args ...interface{})
Lvl2 is more verbose but doesn't spam the stdout in case there is a big simulation
func Lvl3 ¶
func Lvl3(args ...interface{})
Lvl3 gives debug-output that can make it difficult to read for big simulations with more than 100 hosts
func Panicf ¶
func Panicf(f string, args ...interface{})
Panicf is like Panic but with a format-string
func ParseEnv ¶
func ParseEnv()
ParseEnv looks at the following environment-variables: - DEBUG_LVL - for the actual debug-lvl - default is 1 - DEBUG_TIME - whether to show the timestamp - default is false - DEBUG_COLOR - whether to color the output - default is true
func Printf ¶
func Printf(f string, args ...interface{})
Printf is like Print but takes a formatting-argument first
func SetDebugVisible ¶
func SetDebugVisible(lvl int)
SetDebugVisible set the global debug output level in a go-rountine-safe way
func SetShowTime ¶
func SetShowTime(show bool)
SetShowTime allows for turning on the flag that adds the current time to the debug-output
func SetUseColors ¶
func SetUseColors(show bool)
SetUseColors can turn off or turn on the use of colors in the debug-output
func ShowTime ¶
func ShowTime() bool
ShowTime returns the current setting for showing the time in the debug output
func TestOutput ¶
TestOutput sets the DebugVisible to 0 if 'show' is false, else it will set DebugVisible to 'level'
Usage: TestOutput( test.Verbose(), 2 )
Types ¶
This section is empty.