events

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package events is a small event logging system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger added in v1.4.0

func Logger(ctx context.Context) *slog.Logger

Logger returns a slog.Logger for recording current "request" (whatever that means in context) events.

The returned Logger may simply ignore all events. See WithHandler for setting the backing slog.Handler.

func WithGroup deprecated

func WithGroup(ctx context.Context, _ *Group) context.Context

WithGroup returns a Context with the provided Group embedded.

Functions further down the call stack can derive Log interfaces with FromContext.

Deprecated: This was never used, and will not return a child context.Context.

func WithHandler added in v1.4.0

func WithHandler(ctx context.Context, h slog.Handler) context.Context

WithHandler sets the provided slog.Handler to be used when calls to Logger are made with the returned context.Context.

Types

type Event deprecated

type Event struct {
	Message string
	Error   bool
	// contains filtered or unexported fields
}

Event is the event information delivered to a Sink.

Deprecated: This was never used.

type Group deprecated

type Group struct{}

Group is a grouping of log events going to a common Sink.

Deprecated: This was never used.

func NewGroup deprecated

func NewGroup(_ context.Context, _ Sink, _ string) (*Group, error)

NewGroup creates a new Group "name" writing to Sink "sink".

The passed Context is only used for the duration of the NewGroup call.

Deprecated: This was never used.

func (*Group) Finish deprecated

func (g *Group) Finish(_ context.Context) error

Finish signals to the underlying sink that this group is done and reports any errors accumulated by derived Log objects.

Deprecated: This was never used.

type Log deprecated

type Log interface {
	Printf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	// Finish should be called in a defer, right after FromContext.
	Finish()
}

Log is the facade that "user" code should expect.

Deprecated: This was never used.

func FromContext deprecated

func FromContext(_ context.Context, _ string) Log

FromContext returns a Log implementation grouping messages under the provided topic.

The returned implementation may be all no-op methods, so callers should avoid logging "expensive" data.

Deprecated: This was never used, and will return a no-op implementation.

type Sink deprecated

type Sink interface {
	// StartGroup is called when a new group is created. The Context should only
	// be used for the duration of the StartGroup call.
	StartGroup(ctx context.Context, group string) error
	// Topic notifies the Sink that a topic has been started. The same topic may
	// be passed multiple times.
	Topic(string)
	// Event is called once per event, some time between StartGroup and
	// FinishGroup.
	Event(group, topic string, ev Event) error
	// FinishGroup is called when the group is finished. The Context may be
	// canceled when this method is called.
	FinishGroup(ctx context.Context, group string) error
}

Sink is the interface that event sinks must implement.

Deprecated: This was never used.

Jump to

Keyboard shortcuts

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