package dbg

import "git.wntrmute.dev/kyle/goutils/dbg"

Package dbg implements a debug printer.

Index

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.

Source Files

dbg.go

Version
v1.7.7 (latest)
Published
Jun 15, 2024
Platform
linux/amd64
Imports
3 packages
Last checked
4 days ago

Tools for package owners.