debug

package
v0.0.0-...-9413c1f Latest Latest
Warning

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

Go to latest
Published: May 15, 2015 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package debug provides log and trace facilities as enabled or disabled with these build tags: fixme, diag, nolog, notrace.

Index

Constants

View Source
const (
	DefaultDepth = 2
	TraceSize    = 64
)

Variables

View Source
var Trace = &Tracer{}

Functions

func Create

func Create(fn string) (*os.File, error)

Create (or truncate) then chmod the named log file.

func FilterDepth

func FilterDepth(v ...interface{}) (int, []interface{})

FilterDepth strips any such parameter given as the first or last item of the variadic argument.

Usage:

debuf.FilterDepth(debug.Depth(3), err)

func Redirect

func Redirect(v interface{}) error

Redirect all debug loggers.

Types

type Debug

type Debug string

Include Debug as an annonymous member of any structure to add FIXME[f], Diag[f], Log, and Trace methods.

Usage:

var foo struct {
	debug.Debug
	...
}

...

	foo.Debug.Set("foo")
	...
	foo.FIXME(...)
	foo.Diag(...)
	foo.Log(...)
	foo.Trace(...)

func (*Debug) Depth

func (x *Debug) Depth(v ...interface{}) (int, []interface{})

Depth strips any such parameter given as the first or last item of the variadic argument.

Usage:

foo.Diag(debug.Depth(3), err)

func (*Debug) Diag

func (x *Debug) Diag(v ...interface{})

Diag, after stripping any leading or trailing DEPTH parameters, sends Println(v...) output to the Diag logger; either syslog INFO or a redirected file.

func (*Debug) Diagf

func (x *Debug) Diagf(format string, v ...interface{})

Diagf sends Printf(format, v...) output to the Diag logger.

func (*Debug) Failure

func (x *Debug) Failure(v ...interface{})

Failure, after stripping any leading or trailing DEPTH parameters, sends Println(v...) output to the Failure logger; either syslog DEBUG or a redirected file.

func (*Debug) Failuref

func (x *Debug) Failuref(format string, v ...interface{})

Failure sends Printf(format, v...) output to the Failure logger.

func (*Debug) Fixme

func (x *Debug) Fixme(v ...interface{})

Fixme, after stripping any leading or trailing DEPTH parameters, sends Println(v...) output to the Fixme logger; either syslog DEBUG or a redirected file.

func (*Debug) Fixmef

func (x *Debug) Fixmef(format string, v ...interface{})

Fixmef sends Printf(format, v...) output to the Fixme logger.

func (*Debug) Log

func (x *Debug) Log(v ...interface{})

Log sends Println(v...) output to the logger; either syslog NOTICE or a redirected file.

func (*Debug) Logf

func (x *Debug) Logf(format string, v ...interface{})

Logf sends Printf(format, v...) output to the logger.

func (*Debug) Reset

func (x *Debug) Reset()

Reset the prefix.

func (*Debug) Set

func (x *Debug) Set(v interface{}) (err error)

Set the prefix.

func (*Debug) String

func (x *Debug) String() string

String returns prefix.

func (*Debug) Trace

func (x *Debug) Trace(v ...interface{})

Trace adds Println(v...) output to the circular ring.

type Depth

type Depth int

Depth may be included as the first or last variadic parameter to the Diag and FIXME methods to change the back trace from the default, 2.

type Id

type Id uint8

If the first (*Debug).Trace() parameter is an Id, it's used as a key in the trace filter map that qualifies whether the remaining variadic arguments are Println()'d to the trace ring.

type Logger

type Logger struct {
	*log.Logger
}

Logger is a wrapper for the standard library.

var Failure, Fixme, Diag, Log *Logger

func (*Logger) Redirect

func (l *Logger) Redirect(v interface{}) error

Redirect output to given or named file.

func (*Logger) Write

func (l *Logger) Write(b []byte) (int, error)

type Tracer

type Tracer struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Tracer) Filter

func (trace *Tracer) Filter(id Id)

Filter tracing of the given Id.

func (*Tracer) Resize

func (trace *Tracer) Resize(n int)

Reset and resize the trace ring.

func (*Tracer) Unfilter

func (trace *Tracer) Unfilter(id Id)

Unfilter tracing of the given Id.

func (*Tracer) Write

func (trace *Tracer) Write(b []byte) (int, error)

Write to the current ring buffer.

func (*Tracer) WriteTo

func (trace *Tracer) WriteTo(w io.Writer) (int64, error)

LIFO write each non-empty trace ring buffer to the given writer.

Directories

Path Synopsis
Package accumulator provides an integer wrapper with a pointer receiver method to sum results of Read, ReadFrom, Write and WriteTo signatures.
Package accumulator provides an integer wrapper with a pointer receiver method to sum results of Read, ReadFrom, Write and WriteTo signatures.
Package file provides a wrapper to os.File that, when built with both "diag" and "file" tags (e.g.
Package file provides a wrapper to os.File that, when built with both "diag" and "file" tags (e.g.
Package mutex provides a wrapper interface to sync.Mutex that, when built with both "diag" and "mutex" tags (e.g.
Package mutex provides a wrapper interface to sync.Mutex that, when built with both "diag" and "mutex" tags (e.g.

Jump to

Keyboard shortcuts

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