logging

package
v4.0.0-...-04941ef Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DedupLogger

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

DedupLogger wraps a time-ordered log set to allow batched logging of unique messages. Operations on DedupLogger are safe to use concurrently.

func NewLogger

func NewLogger(ctx context.Context, host host.HostClient, urn resource.URN) *DedupLogger

NewLogger returns an initialized DedupLogger.

func (*DedupLogger) EnqueueMessage

func (l *DedupLogger) EnqueueMessage(severity diag.Severity, s string)

EnqueueMessage adds a message to the log set but does not log it to the host.

func (*DedupLogger) GetNewMessages

func (l *DedupLogger) GetNewMessages() []logging.Message

GetNewMessages returns the list of new messages since last calling GetNewMessages.

func (*DedupLogger) LogMessage

func (l *DedupLogger) LogMessage(msg logging.Message)

LogMessage adds a message to the log set and flushes the queue to the host.

func (*DedupLogger) LogNewMessages

func (l *DedupLogger) LogNewMessages()

LogNewMessages logs any new messages to the host.

type LogWriter

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

logWriter is an io.Writer that writes to a logging function, buffering as necessary.

func NewLogWriter

func NewLogWriter(l logF, opts ...Option) *LogWriter

NewLogWriter builds and returns an io.Writer that writes messages to the given logging function. It ensures that each line is logged separately.

Any trailing buffered text that does not end with a newline is flushed when the writer flushes.

The returned writer is safe for concurrent use.

func (*LogWriter) Close

func (w *LogWriter) Close() error

func (*LogWriter) Flush

func (w *LogWriter) Flush()

flush flushes buffered text, even if it doesn't end with a newline.

func (*LogWriter) Write

func (w *LogWriter) Write(bs []byte) (int, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithPrefix

func WithPrefix(prefix string) Option

WithPrefix prepends the given prefix to each line.

type TimeOrderedLogSet

type TimeOrderedLogSet struct {
	Messages logging.Messages
	// contains filtered or unexported fields
}

TimeOrderedLogSet stores a temporally-ordered set of log messages.

func (*TimeOrderedLogSet) Add

func (o *TimeOrderedLogSet) Add(msg logging.Message)

Add appends a message to the time-ordered set.

Jump to

Keyboard shortcuts

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