dbg

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-2.0, GPL-2.0-or-later Imports: 9 Imported by: 0

Documentation

Overview

Package dbg provides yet another stylized debug printer.

Usage:

dbg.Style.Log(args...)
dbg.Style.Logf(format, args...)

Where Style may be: NoOp, Plain, FileLine, or Func.

Nothing is printed with NoOp style, no args, or a nil args[0].

If args[0] is an error, both Log and Logf return that error; otherwise, these return nil. Use this to log a returned error,

return dbg.Style.Log(err)

Use style variables to selectively enable output,

// PACKAGE.go
var Err = dbg.NoOp

	...
	Err.Log(err)
	...

// PACKAGE_test.go
func TestMain(m *testing.M) {
	flag.Parse()
	if testing.Verbose() {
		Err = dbg.FileLine
	}
	os.Exit(m.Run())
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Writer

func Writer(w io.Writer)

Atomic change of the os.Stdout default.

Types

type Style

type Style int

Styles: NoOp, Plain, FilLine, or Func.

const (
	NoOp     Style = iota
	Plain          // TEXT
	FileLine       // github.com/platinasystems/dbg_test.go:22: TEXT
	Func           // github.com/platinasystems/dbg.Test() TEXT

)

func (Style) Log

func (style Style) Log(args ...interface{}) error

Print style prefix, then args formated with fmt.Println.

func (Style) Logf

func (style Style) Logf(format string, args ...interface{}) error

Print style prefix, then args formatted with fmt.Printf, and end with newline.

func (Style) String

func (style Style) String() string

Return name of style.

type Syncer added in v1.18.1

type Syncer interface {
	Sync() error
}

Jump to

Keyboard shortcuts

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