mlog

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mlog contains utilities for logging about messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatID

func FormatID(id string) string

FormatID formats a message ID for logging.

If the message ID appears to be a UUID, only the first 8 characters are shown. Otherwise, the ID is displayed in-full.

func LogConsume

func LogConsume(
	log logging.Logger,
	env *envelopespec.Envelope,
	fc uint,
)

LogConsume logs a message indicating that a Dogma message is being consumed.

func LogFromScope

func LogFromScope(
	log logging.Logger,
	env *envelopespec.Envelope,
	f string, v []interface{},
)

LogFromScope logs an informational message produced within a Dogma handler via a scope.

func LogHandlerResult

func LogHandlerResult(
	log logging.Logger,
	env *envelopespec.Envelope,
	handler *envelopespec.Identity,
	ht configkit.HandlerType,
	err *error,
	f string, v ...interface{},
)

LogHandlerResult logs a debug message produced by the engine for a specific Dogma handler.

It is designed to be used with defer.

func LogNack

func LogNack(
	log logging.Logger,
	env *envelopespec.Envelope,
	cause error,
	delay time.Duration,
)

LogNack logs a message indicating that a request has been Nack'd.

func LogProduce

func LogProduce(
	log logging.Logger,
	env *envelopespec.Envelope,
)

LogProduce logs a message indicating that Dogma message is being produced.

func String

func String(
	ids []IconWithLabel,
	icons []Icon,
	text ...string,
) string

String returns a log line as a string.

func Write

func Write(
	w io.Writer,
	ids []IconWithLabel,
	icons []Icon,
	text ...string,
) (n int, err error)

Write writes a log line to w.

Types

type Icon

type Icon string

Icon is a unicode symbol used as an icon in log messages.

const (
	// TransactionIDIcon is the icon shown directly before a transaction ID. It
	// is a circle with a dot in the center, intended to be reminiscent of an
	// electron circling a nucleus, indicating "atomicity". There is a unicode
	// atom symbol, however it does not tend to be discernable at smaller font
	// sizes.
	TransactionIDIcon Icon = "⨀"

	// MessageIDIcon is the icon shown directly before a message ID.
	// It is an "equals sign", indicating that this message "has exactly" the
	// displayed ID.
	MessageIDIcon Icon = "="

	// CausationIDIcon is the icon shown directly before a message causation ID.
	// It is the mathematical "because" symbol, indicating that this message
	// happened "because of" the displayed ID.
	CausationIDIcon Icon = "∵"

	// CorrelationIDIcon is the icon shown directly before a message correlation
	// ID. It is the mathematical "member of set" symbol, indicating that this
	// message belongs to the set of messages that came about because of the
	// displayed ID.
	CorrelationIDIcon Icon = "⋲"

	// ConsumeIcon is the icon shown to indicate that a message is being
	// consumed. It is a downward pointing arrow, as such "inbound" messages
	// could be considered as being "downloaded" from the network or queue.
	ConsumeIcon Icon = "▼"

	// ConsumeErrorIcon is a variant of ConsumeIcon used when there is an error
	// condition. It is an hollow version of the regular consume icon,
	// indicating that the requirement remains "unfulfilled".
	ConsumeErrorIcon Icon = "▽"

	// ProduceIcon is the icon shown to indicate that a message is being
	// produce. It is an upward pointing arrow, as such "outbound" messages
	// could be considered as being "uploaded" to the network or queue.
	ProduceIcon Icon = "▲"

	// ProduceErrorIcon is a variant of ProduceIcon used when there is an error
	// condition. It is an hollow version of the regular produce icon,
	// indicating that the requirement remains "unfulfilled".
	ProduceErrorIcon Icon = "△"

	// RetryIcon is an icon used instead of ConsumeIcon when a message is being
	// re-attempted. It is an open-circle with an arrow, indicating that the
	// message has "come around again".
	RetryIcon Icon = "↻"

	// ErrorIcon is the icon shown when logging information about an error.
	// It is a heavy cross, indicating a failure.
	ErrorIcon Icon = "✖"

	// AggregateIcon is the icon shown when a log message relates to an
	// aggregate message handler. It is the mathematical "therefore" symbol,
	// representing the decision making as a result of the message.
	AggregateIcon Icon = "∴"

	// ProcessIcon is the icon shown when a log message relates to a process
	// message handler. It is three horizontal lines, representing the step in a
	// process.
	ProcessIcon Icon = "≡"

	// IntegrationIcon is the icon shown when a log message relates to an
	// integration message handler. It is the relational algebra "join" symbol,
	// representing the integration of two systems.
	IntegrationIcon Icon = "⨝"

	// ProjectionIcon is the icon shown when a log message relates to a
	// projection message handler. It is the mathematical "sum" symbol ,
	// representing the aggregation of events.
	ProjectionIcon Icon = "Σ"

	// SystemIcon is an icon shown when a log message relates to the internals
	// of the engine. It is a sprocket, representing the inner workings of the
	// machine.
	SystemIcon Icon = "⚙"

	// SeparatorIcon is an icon used to separate strings of unrelated text
	// inside a log message. It is a large bullet, intended to have a large
	// visual impact.
	SeparatorIcon Icon = "●"
)

func HandlerTypeIcon

func HandlerTypeIcon(t configkit.HandlerType) Icon

HandlerTypeIcon returns the icon to use for the given handler type.

func (Icon) String

func (i Icon) String() string

func (Icon) WithID

func (i Icon) WithID(id string) IconWithLabel

WithID return an IconWithLabel containing this icon and an ID as its label.

The id is formatted using FormatID().

func (Icon) WithLabel

func (i Icon) WithLabel(f string, v ...interface{}) IconWithLabel

WithLabel return an IconWithLabel containing this icon and the given label.

func (Icon) WriteTo

func (i Icon) WriteTo(w io.Writer) (int64, error)

WriteTo writes a string representation of the icon to w. If i is the zero-value, a single space is rendered.

type IconWithLabel

type IconWithLabel struct {
	Icon  Icon
	Label string
}

IconWithLabel is a container for an icon and its associated text label.

func (IconWithLabel) String

func (i IconWithLabel) String() string

func (IconWithLabel) WriteTo

func (i IconWithLabel) WriteTo(w io.Writer) (_ int64, err error)

WriteTo writes a string representation of the icon and its label to w.

Jump to

Keyboard shortcuts

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