dbg

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: BSD-2-Clause, ISC Imports: 3 Imported by: 0

Documentation

Overview

Package dbg implements a debug printer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DebugPrinter

type DebugPrinter struct {
	// If Enabled is false, the print statements won't do anything.
	Enabled bool
	// contains filtered or unexported fields
}

A DebugPrinter is a drop-in replacement for fmt.Print*, and also acts as an io.WriteCloser when enabled.

func New

func New() *DebugPrinter

New returns a new DebugPrinter on os.Stdout.

func To

To sets up a new DebugPrint to an io.WriteCloser.

func ToFile

func ToFile(path string) (*DebugPrinter, error)

ToFile sets up a new DebugPrinter to a file, truncating it if it exists.

func (*DebugPrinter) Close

func (dbg *DebugPrinter) Close() error

Close satisfies the Closer interface.

func (*DebugPrinter) Print

func (dbg *DebugPrinter) Print(v ...interface{})

Print calls fmt.Print if Enabled is true.

func (*DebugPrinter) Printf

func (dbg *DebugPrinter) Printf(format string, v ...interface{})

Printf calls fmt.Printf if Enabled is true.

func (*DebugPrinter) Println

func (dbg *DebugPrinter) Println(v ...interface{})

Println calls fmt.Println if Enabled is true.

func (*DebugPrinter) Write

func (dbg *DebugPrinter) Write(p []byte) (int, error)

Write satisfies the Writer interface.

Jump to

Keyboard shortcuts

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