debug

package
v0.0.0-...-2eeca3e Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 8 Imported by: 2

README

debug - Old school debugging with logging

Proposed package for debugging aids. See examples for some trivial samples.

Documentation

Index

Constants

View Source
const EnableEnvVar = "ENABLE_DEBUG"

EnableEnvVar is the name of an environment variable that, if set, will enable this package's functionality.

Variables

This section is empty.

Functions

func Assert

func Assert(expr bool, v ...interface{})

Assert will panic if expression is not true, but only if debugging is enabled

func Assertf

func Assertf(expr bool, f string, v ...interface{})

Assertf will panic if expression is not true, but only if debugging is enabled

func Disable

func Disable()

Disable disables debug logging

func Enable

func Enable()

Enable enables debug logging

func Enabled

func Enabled() bool

Enabled returns a bool indicating whether or not debugging is enabled

func Output

func Output(skip int, msg string)

Output prints message if debug logging is enabled.

func Print

func Print(v ...interface{})

Print prints arguments if debug logging is enabled.

func Printf

func Printf(f string, v ...interface{})

Printf prints message if debug logging is enabled.

func SetOutput

func SetOutput(out io.Writer)

SetOutput configures the output writer for the wrapped *log.Logger

func Shell

func Shell(cmd string, args ...string)

Shell runs command only in debug mode.

func Writer

func Writer() *external.Writer

Writer returns a new *external.Writer suitable for injection into 3rd-party logging packages.

Types

type Debugger

type Debugger struct {
	// contains filtered or unexported fields
}

Debugger wraps a *log.Logger with some configuration and convenience methods

func NewDebugger

func NewDebugger(out io.Writer) *Debugger

NewDebugger creates a new *Debugger which logs to the supplied io.Writer

func (*Debugger) Assert

func (d *Debugger) Assert(expr bool, v ...interface{})

Assert accepts a boolean expression and arguments, which if the expression is false, will be printed before panicing.

func (*Debugger) Assertf

func (d *Debugger) Assertf(expr bool, f string, v ...interface{})

Assertf accepts a boolean expression and formatted arguments, which if the expression is false, will be printed before panicing.

func (*Debugger) Disable

func (d *Debugger) Disable()

Disable turns off debug logging

func (*Debugger) Enable

func (d *Debugger) Enable()

Enable turns on debug logging

func (*Debugger) Enabled

func (d *Debugger) Enabled() bool

Enabled indicates whether or not debugging is enabled

func (*Debugger) Output

func (d *Debugger) Output(skip int, s string)

Output writes the output for a logging event

func (*Debugger) Print

func (d *Debugger) Print(v ...interface{})

Print outputs the arguments

func (*Debugger) Printf

func (d *Debugger) Printf(f string, v ...interface{})

Printf outputs formatted arguments

func (*Debugger) SetOutput

func (d *Debugger) SetOutput(out io.Writer)

SetOutput configures the output writer for the debugger's logger

func (*Debugger) Write

func (d *Debugger) Write(data []byte) (int, error)

Write implements io.Writer and allows the debugger to be used as a log writer.

func (*Debugger) Writer

func (d *Debugger) Writer() *external.Writer

Writer returns a new *external.Writer suitable for injection into 3rd-party logging packages.

type Flag

type Flag bool

Flag allows the flag package to enable debugging

func FlagVar

func FlagVar() (*Flag, string, string)

FlagVar returns a tuple of parameters suitable for flag.Var()

func (*Flag) IsBoolFlag

func (f *Flag) IsBoolFlag() bool

IsBoolFlag satisfies the flag.boolFlag interface

func (*Flag) Set

func (f *Flag) Set(value string) error

Set satisfies the flag.Value interface

func (*Flag) String

func (f *Flag) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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