log

package
v2.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIdentity

func FormatIdentity(name string, description string) string

FormatIdentity formats a name and an optional description in the form '<b>name</b>[ description]'.

Types

type IdentifiableError

type IdentifiableError struct {
	// Name is the name of the identified object.
	Name string

	// Description is the description of the identified object.
	Description string

	// Err is the nested error.
	Err error
}

IdentifiableError is an error associated with an Identifiable for logging purposes.

func (IdentifiableError) Error

func (i IdentifiableError) Error() string

type Logger

type Logger interface {
	log.Logger

	Body(a ...interface{})
	Bodyf(format string, a ...interface{})
	BodyWriter() io.Writer
	IsBodyEnabled() bool

	Header(a ...interface{})
	Headerf(format string, a ...interface{})
	HeaderWriter() io.Writer
	IsHeaderEnabled() bool

	TerminalError(err IdentifiableError)
	TerminalErrorWriter() io.Writer
	IsTerminalErrorEnabled() bool

	Title(name string, version string, homepage string)
	Titlef(format string, a ...interface{})
	TitleWriter() io.Writer
	IsTitleEnabled() bool
}

type Option

type Option func(logger PaketoLogger) PaketoLogger

Option is a function for configuring a Logger instance.

type PaketoLogger

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

Logger logs message to a writer.

func NewDiscardLogger

func NewDiscardLogger() PaketoLogger

NewDiscardLogger creates a new instance of PaketoLogger that discards all log messages. Useful in testing.

func NewPaketoLogger

func NewPaketoLogger(writer io.Writer) PaketoLogger

NewPaketoLogger creates a new instance of PaketoLogger. It configures debug logging if $BP_DEBUG is set.

func NewPaketoLoggerWithOptions

func NewPaketoLoggerWithOptions(writer io.Writer, options ...Option) PaketoLogger

func (PaketoLogger) Body

func (l PaketoLogger) Body(a ...interface{})

Body formats using the default formats for its operands and logs a message to the configured body writer. Spaces are added between operands when neither is a string.

func (PaketoLogger) BodyWriter

func (l PaketoLogger) BodyWriter() io.Writer

BodyWriter returns the configured body writer.

func (PaketoLogger) Bodyf

func (l PaketoLogger) Bodyf(format string, a ...interface{})

Bodyf formats according to a format specifier and logs a message to the configured body writer.

func (PaketoLogger) Debug

func (l PaketoLogger) Debug(a ...interface{})

Debug formats using the default formats for its operands and writes to the configured debug writer. Spaces are added between operands when neither is a string.

func (PaketoLogger) DebugWriter

func (l PaketoLogger) DebugWriter() io.Writer

DebugWriter returns the configured debug writer.

func (PaketoLogger) Debugf

func (l PaketoLogger) Debugf(format string, a ...interface{})

Debugf formats according to a format specifier and writes to the configured debug writer.

func (PaketoLogger) Header

func (l PaketoLogger) Header(a ...interface{})

Header formats using the default formats for its operands and logs a message to the configured header writer. Spaces are added between operands when neither is a string.

func (PaketoLogger) HeaderWriter

func (l PaketoLogger) HeaderWriter() io.Writer

HeaderWriter returns the configured header writer.

func (PaketoLogger) Headerf

func (l PaketoLogger) Headerf(format string, a ...interface{})

Headerf formats according to a format specifier and logs a message to the configured header writer.

func (PaketoLogger) IsBodyEnabled

func (l PaketoLogger) IsBodyEnabled() bool

IsBodyEnabled indicates whether body logging is enabled.

func (PaketoLogger) IsDebugEnabled

func (l PaketoLogger) IsDebugEnabled() bool

IsDebugEnabled indicates whether debug logging is enabled.

func (PaketoLogger) IsHeaderEnabled

func (l PaketoLogger) IsHeaderEnabled() bool

IsHeaderEnabled indicates whether header logging is enabled.

func (PaketoLogger) IsTerminalErrorEnabled

func (l PaketoLogger) IsTerminalErrorEnabled() bool

IsTerminalErrorEnabled indicates whether terminal error logging is enabled.

func (PaketoLogger) IsTitleEnabled

func (l PaketoLogger) IsTitleEnabled() bool

IsTitleEnabled indicates whether title logging is enabled.

func (PaketoLogger) TerminalError

func (l PaketoLogger) TerminalError(err IdentifiableError)

TerminalError logs a message to the configured terminal error writer.

func (PaketoLogger) TerminalErrorWriter

func (l PaketoLogger) TerminalErrorWriter() io.Writer

TerminalErrorWriter returns the configured terminal error writer.

func (PaketoLogger) Title

func (l PaketoLogger) Title(name string, version string, homepage string)

func (PaketoLogger) TitleWriter

func (l PaketoLogger) TitleWriter() io.Writer

TitleWriter returns the configured title writer.

func (PaketoLogger) Titlef

func (l PaketoLogger) Titlef(format string, a ...interface{})

type Writer

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

Writer is an object that will indent and color all output flowing through it.

func NewWriter

func NewWriter(writer io.Writer, options ...WriterOption) *Writer

NewWriter creates a instance that wraps another writer.

func (*Writer) Write

func (w *Writer) Write(b []byte) (int, error)

type WriterOption

type WriterOption func(Writer) Writer

WriterOption is a function for configuring a Writer instance.

func WithAttributes

func WithAttributes(attributes ...color.Attribute) WriterOption

WithAttributes creates an WriterOption that sets the output color.

func WithIndent

func WithIndent(indent int) WriterOption

WithIndent creates an WriterOption that sets the depth of the output indent.

Jump to

Keyboard shortcuts

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