dbglog

package module
v0.0.0-...-efbc47a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2013 License: BSD-2-Clause Imports: 2 Imported by: 1

README

dbglog

Logger that adds debug and subsystems.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbgLogger

type DbgLogger struct {
	*log.Logger
	// contains filtered or unexported fields
}

Opaque receiver type used by the dbglog package.

func New

func New(out io.Writer, prefix string, flag int) *DbgLogger

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

func (d *DbgLogger) DebugM(bit uint64, format string, v ...interface{})

log.Print equivalent but only prints when debug is enabled and bit is enabled in the mask.

func (*DbgLogger) Debugf

func (d *DbgLogger) Debugf(format string, v ...interface{})

log.Printf equivalent but only prints when debug is enabled.

func (*DbgLogger) DebugfM

func (d *DbgLogger) DebugfM(bit uint64, format string, v ...interface{})

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

func (d *DbgLogger) DebuglnM(bit uint64, format string, v ...interface{})

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.

func (*DbgLogger) Enable

func (d *DbgLogger) Enable()

In order for the Debug functions to print the Enable function must be called. This is a runtime function that can be called at any time.

func (*DbgLogger) SetMask

func (d *DbgLogger) SetMask(mask uint64)

SetMask sets the mask for the Debug*M functions. This mask is considered a bitfield.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL