logging

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

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 *provider.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() []Message

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

func (*DedupLogger) LogMessage

func (l *DedupLogger) LogMessage(msg 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 Message

type Message struct {
	S        string
	Severity diag.Severity
}

Message stores a log string and the severity for the log message.

func ErrorMessage

func ErrorMessage(msg string) Message

ErrorMessage creates a Message with Severity set to Error.

func StatusMessage

func StatusMessage(msg string) Message

StatusMessage creates a Message with Severity set to Info.

func WarningMessage

func WarningMessage(msg string) Message

WarningMessage creates a Message with Severity set to Warning.

func (Message) Empty

func (m Message) Empty() bool

Empty returns true if the Message is uninitialized, false otherwise.

func (Message) String

func (m Message) String() string

type Messages

type Messages []Message

Messages is a slice of Message types.

func (Messages) Errors

func (m Messages) Errors() Messages

Errors returns Messages with Error severity.

func (Messages) Infos

func (m Messages) Infos() Messages

Infos returns Messages with Info severity.

func (Messages) MessagesWithSeverity

func (m Messages) MessagesWithSeverity(sev ...diag.Severity) Messages

MessagesWithSeverity returns Messages matching any of the provided Severity levels.

func (Messages) Warnings

func (m Messages) Warnings() Messages

Warnings returns Messages with Warning severity.

type TimeOrderedLogSet

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

TimeOrderedLogSet stores a temporally-ordered set of log messages.

func (*TimeOrderedLogSet) Add

func (o *TimeOrderedLogSet) Add(msg 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