Documentation ¶
Overview ¶
Package pdebug provides tools to produce debug logs the way the author (Daisuke Maki a.k.a. lestrrat) likes. All of the functions are no-ops unless you compile with the `-tags debug` option.
When you compile your program with `-tags debug`, no trace is displayed, but the code enclosed within `if pdebug.Enabled { ... }` is compiled in. To show the debug trace, set the PDEBUG_TRACE environment variable to true (or 1, or whatever `strconv.ParseBool` parses to true)
If you want to show the debug trace regardless of an environment variable, for example, perhaps while you are debugging or running tests, use the `-tags debug0` build tag instead. This will enable the debug trace forcefully
Index ¶
Constants ¶
const Enabled = false
Enabled is true if `-tags debug` or `-tags debug0` is used during compilation. Use this to "ifdef-out" debug blocks.
const Trace = false
Trace is true if `-tags debug` is used AND the environment variable `PDEBUG_TRACE` is set to a `true` value (i.e., 1, true, etc), or `-tags debug0` is used. This allows you to compile-in the trace logs, but only show them when you set the environment variable
Variables ¶
var DefaultCtx = &pdctx{ LogTime: true, Prefix: "|DEBUG| ", Writer: os.Stdout, }
Functions ¶
func Dump ¶
func Dump(v ...interface{})
Dump dumps the objects using go-spew. Dump is a no op unless you compile with the `debug` tag.
func IPrintf ¶
func IPrintf(f string, args ...interface{}) guard
IPrintf is deprecated. Use Marker()/End() instead
func Marker ¶
func Marker(f string, args ...interface{}) *markerg
Marker marks the beginning of an indented block. The message you specify in the arguments is prefixed witha "START", and subsequent calls to Printf will be indented one level more.
To reset this, you must call End() on the guard object that gets returned by Marker().
Types ¶
This section is empty.