logging

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FmtLogger

type FmtLogger struct{}

func Default

func Default() *FmtLogger

func (*FmtLogger) Debug

func (l *FmtLogger) Debug(message string)

Debug logs at the DEBUG log level

func (*FmtLogger) Error

func (l *FmtLogger) Error(message string)

Error logs at the ERROR log level

func (*FmtLogger) ErrorWithContext

func (l *FmtLogger) ErrorWithContext(err error, sub string, ctx ...string)

ErrorWithContext logs at the ERROR log level including additional context so users can easily identify issues.

func (*FmtLogger) Info

func (l *FmtLogger) Info(message string)

Info logs at the INFO log level

func (*FmtLogger) Trace

func (l *FmtLogger) Trace(message string)

Trace logs at the TRACE log level

func (*FmtLogger) Warning

func (l *FmtLogger) Warning(message string)

Warning logs at the WARN log level

type Logger

type Logger interface {
	// Debug logs at the DEBUG log level
	Debug(message string)

	// Error logs at the ERROR log level
	Error(message string)

	// ErrorWithContext logs at the ERROR log level including additional context so
	// users can easily identify issues.
	ErrorWithContext(err error, sub string, ctx ...string)

	// Info logs at the INFO log level
	Info(message string)

	// Trace logs at the TRACE log level
	Trace(message string)

	// Warning logs at the WARN log level
	Warning(message string)
}

Logger is the primary interface for logging with a consistent interface without creating a hard dependency between the UI layer and lower layers of the stack. It is inspired a subset of the functions defined by terminal.UI which are generic enough for lower level packages to consume. It expected that implementations of this interface will respect the NOMAD_PACK_LOG_LEVEL environment variable.

type TestLogger

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

func NewTestLogger

func NewTestLogger(log func(args ...any)) *TestLogger

NewTestLogger returns a test logger suitable for use with the go testing.T log function.

func (*TestLogger) Debug

func (l *TestLogger) Debug(message string)

Debug logs at the DEBUG log level

func (*TestLogger) Error

func (l *TestLogger) Error(message string)

Error logs at the ERROR log level

func (*TestLogger) ErrorWithContext

func (l *TestLogger) ErrorWithContext(err error, sub string, ctx ...string)

ErrorWithContext logs at the ERROR log level including additional context so users can easily identify issues.

func (*TestLogger) Info

func (l *TestLogger) Info(message string)

Info logs at the INFO log level

func (*TestLogger) Trace

func (l *TestLogger) Trace(message string)

Trace logs at the TRACE log level

func (*TestLogger) Warning

func (l *TestLogger) Warning(message string)

Warning logs at the WARN log level

Jump to

Keyboard shortcuts

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