trace

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 3 Imported by: 13

Documentation

Overview

Package trace provides a decorator for io.ReadWriter that logs all reads and writes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger added in v0.2.0

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger defines the interface used to log trace messages.

type Option

type Option func(*Trace)

Option modifies a Trace object created by New.

func WithLogger added in v0.2.0

func WithLogger(l Logger) Option

WithLogger specifies the logger to be used to log trace messages.

By default traces are logged to Stdout.

func WithReadFormat added in v0.2.0

func WithReadFormat(format string) Option

WithReadFormat sets the format used for read logs.

func WithWriteFormat added in v0.2.0

func WithWriteFormat(format string) Option

WithWriteFormat sets the format used for write logs.

type Trace

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

Trace is a trace log on an io.ReadWriter.

All reads and writes are written to the logger.

func New

func New(rw io.ReadWriter, options ...Option) *Trace

New creates a new trace on the io.ReadWriter.

func (*Trace) Read

func (t *Trace) Read(p []byte) (n int, err error)

func (*Trace) Write

func (t *Trace) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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