Documentation
¶
Overview ¶
Package events is a small event logging system.
Index ¶
- func Logger(ctx context.Context) *slog.Logger
- func WithGroup(ctx context.Context, _ *Group) context.Contextdeprecated
- func WithHandler(ctx context.Context, h slog.Handler) context.Context
- type Eventdeprecated
- type Groupdeprecated
- type Logdeprecated
- type Sinkdeprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Logger ¶ added in v1.4.0
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 WithHandler ¶ added in v1.4.0
WithHandler sets the provided slog.Handler to be used when calls to Logger are made with the returned context.Context.
Types ¶
type Group
deprecated
type Group struct{}
Group is a grouping of log events going to a common Sink.
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
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.