tools

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPrintable

func IsPrintable[T printableType](v T) string

Types

type BufLogReadWriter

type BufLogReadWriter struct {
	io.Writer
	*bufio.Reader
}

func NewBufLogReadWriter

func NewBufLogReadWriter(rw io.ReadWriter, logger *slog.Logger) *BufLogReadWriter

NewBufLogReadWriter creates a new BufLogReadWriter. It wraps a bufio.ReadWriter and logs all reads and writes to a slog.Logger. the reason to divide it in 2 structs is to avoid the need to implement all the methods of bufio.ReadWriter

type HttpResponseWriter

type HttpResponseWriter struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

func NewHttpResponseWriter

func NewHttpResponseWriter(w http.ResponseWriter, logger *slog.Logger) *HttpResponseWriter

func (*HttpResponseWriter) Write

func (rw *HttpResponseWriter) Write(b []byte) (int, error)

type LogReadWriter

type LogReadWriter struct {
	ReadWriter io.ReadWriter
	// contains filtered or unexported fields
}

LogReadWriter is a wrapper around a bufio.ReadWriter that logs all reads and writes to a slog.Logger.

func NewLogReadWriter

func NewLogReadWriter(rw io.ReadWriter, logger *slog.Logger) *LogReadWriter

NewLogReadWriter creates a new LogReadWriter.

func (*LogReadWriter) Read

func (rw *LogReadWriter) Read(b []byte) (int, error)

func (*LogReadWriter) Write

func (rw *LogReadWriter) Write(b []byte) (int, error)

type LogReader

type LogReader struct {
	Reader io.Reader
	// contains filtered or unexported fields
}

func NewLogReader

func NewLogReader(r io.Reader, logger *slog.Logger) *LogReader

func (*LogReader) Read

func (rw *LogReader) Read(b []byte) (int, error)

type LogWriter

type LogWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

func NewLogWriter

func NewLogWriter(w io.Writer, logger *slog.Logger) *LogWriter

func (*LogWriter) Write

func (rw *LogWriter) Write(b []byte) (int, error)

Jump to

Keyboard shortcuts

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