Documentation ¶
Overview ¶
Package dbglog extends the standard log.Logger interface by adding debug functions. There are 2 types of debug functions, ones that always print when enabled and ones that need to satisfy a user supplied mask.
Since the dbglog package is extended from log.Logger, one can use the log.Logger functions as well. I.e. d.Printf("hello\n"). Do read the log pkg documentation as well and note that in order to use the log flags one must import pkg log.
Index ¶
- type DbgLogger
- func (d *DbgLogger) Debug(v ...interface{})
- func (d *DbgLogger) DebugM(bit uint64, format string, v ...interface{})
- func (d *DbgLogger) Debugf(format string, v ...interface{})
- func (d *DbgLogger) DebugfM(bit uint64, format string, v ...interface{})
- func (d *DbgLogger) Debugln(v ...interface{})
- func (d *DbgLogger) DebuglnM(bit uint64, format string, v ...interface{})
- func (d *DbgLogger) Disable()
- func (d *DbgLogger) Enable()
- func (d *DbgLogger) SetMask(mask uint64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbgLogger ¶
Opaque receiver type used by the dbglog package.
func New ¶
Create a new instance of DbgLogger type. out is an io.Writer type, i.e. os.Stderr. prefix is printed in front of the line, this is useful for grepping etc. and flag are the ones used in log.Logger, please see that documentation for more details.
Example:
const ( myDebugOne = 1<<0 myDebugTwo = 1<<1 myDebugThree = 1<<2 ) func main() { d := New(os.Stderr, "myapp ", log.LstdFlags) d.Printf("printme!\n") d.Enable() d.SetMask(myDebugOne) d.DebugfM(myDebugOne, "debug") // prints d.DebugfM(myDebugTwo, "debug") // does NOT print }
func (*DbgLogger) Debug ¶
func (d *DbgLogger) Debug(v ...interface{})
log.Print equivalent but only prints when debug is enabled.
func (*DbgLogger) DebugM ¶
log.Print equivalent but only prints when debug is enabled and bit is enabled in the mask.
func (*DbgLogger) DebugfM ¶
log.Printf equivalent but only prints when debug is enabled and bit is enabled in the mask.
func (*DbgLogger) Debugln ¶
func (d *DbgLogger) Debugln(v ...interface{})
log.Println equivalent but only prints when debug is enabled.
func (*DbgLogger) DebuglnM ¶
log.Println equivalent but only prints when debug is enabled and bit is enabled in the mask.
func (*DbgLogger) Disable ¶
func (d *DbgLogger) Disable()
In order to disable Debug functions call Disable. This is a runtime function that can be called at any time.