util

package
v0.0.0-...-fc4b8ed Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtBytes

func FmtBytes(n int64) string

Types

type Logger

type Logger struct {
	NErrors int
	// contains filtered or unexported fields
}

Logger provides a simple logging system with a few different log levels; debugging and verbose output may both be suppressed independently.

func NewLogger

func NewLogger(verbose, debug bool) *Logger

func (*Logger) Check

func (l *Logger) Check(v bool, msg ...interface{})

Checks the provided condition and prints a fatal error if it's false. The error message includes the source file and line number where the check failed. An optional message specified with printf-style formatting may be provided to print with the error message.

func (*Logger) CheckError

func (l *Logger) CheckError(err error, msg ...interface{})

Similar to Check, CheckError prints a fatal error if the given error is non-nil. It also takes an optional format string.

func (*Logger) Debug

func (l *Logger) Debug(f string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(f string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(f string, args ...interface{})

func (*Logger) Print

func (l *Logger) Print(f string, args ...interface{})

func (*Logger) Verbose

func (l *Logger) Verbose(f string, args ...interface{})

func (*Logger) Warning

func (l *Logger) Warning(f string, args ...interface{})

type ReportingReader

type ReportingReader struct {
	R   io.Reader
	Msg string
	// contains filtered or unexported fields
}

Small wrapper around io.Reader that implements io.ReadCloser. Periodically logs how many bytes have been read and the rate of processing them in bytes / second.

func (*ReportingReader) Close

func (r *ReportingReader) Close() error

func (*ReportingReader) Read

func (r *ReportingReader) Read(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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