log

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: EPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger interface allows implementations to provide to this package any object that implements the methods defined in it.

type NOOPLogger

type NOOPLogger struct{}

NOOPLogger implements the logger that does not perform any operation by default. This allows us to efficiently discard the unwanted messages.

func (NOOPLogger) Printf

func (NOOPLogger) Printf(format string, v ...interface{})

Printf is the library provided NOOPLogger's implementation of the required interface function(){}

func (NOOPLogger) Println

func (NOOPLogger) Println(v ...interface{})

Println is the library provided NOOPLogger's implementation of the required interface function()

type TestLog

type TestLog struct {
	sync.Mutex
	// contains filtered or unexported fields
}

The TestLog type is an adapter to allow the use of testing.T as a paho.Logger. With this implementation, log messages will only be output when a test fails (and will be associated with the test).

func NewTestLogger

func NewTestLogger(l testLogger, prefix string) *TestLog

NewTestLogger accepts a testLogger (e.g. Testing.T) and a prefix (added to messages logged) and returns a Logger

func (*TestLog) Printf

func (t *TestLog) Printf(format string, v ...interface{})

Printf formats its arguments according to the format, analogous to fmt.Printf, and records the text in the test log (only printed if the test files or appropriate arguments passed to go test).

func (*TestLog) Println

func (t *TestLog) Println(v ...interface{})

Println prints a line to the log Println its arguments in the test log (only printed if the test files or appropriate arguments passed to go test).

Jump to

Keyboard shortcuts

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