Documentation ¶
Overview ¶
Package reflect provides a logging layer for exchangers and client
Index ¶
- func GetEnabled(ctx context.Context, name string) (slog.LogLevel, bool)
- func GetID(ctx context.Context) (string, bool)
- func WithEnabled(ctx context.Context, level slog.LogLevel, enabled bool) context.Context
- func WithEnabledFunc(ctx context.Context, cond EnabledFunc) context.Context
- func WithFormattedID(ctx context.Context, id string) context.Context
- func WithID(ctx context.Context, machID uint16, msgID uint16) context.Context
- type Client
- type EnabledFunc
- type Lookuper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetEnabled ¶
GetEnabled tests if the context enables the specified reflection layer or not.
func WithEnabled ¶
WithEnabled attaches an unconditional reflection layer state regardless the name
func WithEnabledFunc ¶
func WithEnabledFunc(ctx context.Context, cond EnabledFunc) context.Context
WithEnabledFunc attaches a function to determine of a reflection layer is enabled or not.
func WithFormattedID ¶
WithFormattedID attaches a tracing ID to the request's context.
Types ¶
type Client ¶
type Client struct { Extra map[string]any Rename map[string]string // contains filtered or unexported fields }
Client is a logging wrapper for another client.Client. Client will log requests and responses if `GetEnabled(ctx)` returns true.
func NewWithClient ¶
NewWithClient creates a new Client wrapper to log requests and responses to the specified client.Client.
type EnabledFunc ¶ added in v0.7.16
EnabledFunc represents the signature of the in-context function used to determine if a request should be logged and at what level
type Lookuper ¶
type Lookuper struct { Extra map[string]any Rename map[string]string // contains filtered or unexported fields }
Lookuper is a logging wrapper for another resolver.Lookuper or resolver.Exchanger Lookuper will log requests and responses if `GetEnabled(ctx)` returns true.
func NewWithExchanger ¶
NewWithExchanger creates a new Lookuper wrapper to log requests and responses to the specified resolver.Exchanger.
func NewWithLookuper ¶
NewWithLookuper creates a new Lookuper wrapper to log requests and responses to the specified resolver.Lookuper. If the next resolver.Lookuper also implements resolver.Exchanger, that interface will be used instead.
func (*Lookuper) Exchange ¶
Exchange implements the resolver.Exchanger interface.