Documentation
¶
Index ¶
- Variables
- func FormatDuration(d time.Duration) string
- type Blackbox
- type Client
- type ClientOption
- type ClientOptions
- type DefaultTool
- func (d *DefaultTool) GetComponent(skip int, withFullFn, withFile, withFilePath, withLine bool) string
- func (d *DefaultTool) Log(ctx context.Context, l contract.Level, v any, prefix string, msg ...string)
- func (d *DefaultTool) Wrap(ctx context.Context, fn func() (any, error)) error
- func (d *DefaultTool) WrapHandler(h contract.HandlerFunc) contract.HandlerFunc
- func (d *DefaultTool) WrapMiddleware(m contract.MiddlewareFunc) contract.MiddlewareFunc
- type Dependencies
- type Key
- type Tool
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func FormatDuration ¶
FormatDuration dynamically chooses the best unit for logging.
Types ¶
type Client ¶
type Client interface {
Blackbox
contract.LogOperator
contract.ComponentExtractor
}
func NewClient ¶
func NewClient(out io.Writer, l contract.Level, d Dependencies, opts ClientOptions) (Client, error)
type ClientOption ¶
type ClientOption = contract.Opt[ClientOptions]
func WithLevelKey ¶
func WithLevelKey(x Key) ClientOption
func WithMaxLen ¶
func WithMaxLen(x uint) ClientOption
func WithMessageKey ¶
func WithMessageKey(x Key) ClientOption
func WithTimeKey ¶
func WithTimeKey(x Key) ClientOption
type ClientOptions ¶
func ApplyClientOptions ¶
func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions
type DefaultTool ¶ added in v0.1.11
type DefaultTool struct {
Client Client
}
func NewTool ¶
func NewTool(c Client) (*DefaultTool, error)
func (*DefaultTool) GetComponent ¶ added in v0.1.11
func (d *DefaultTool) GetComponent(skip int, withFullFn, withFile, withFilePath, withLine bool) string
GetComponent returns a component string.
func (*DefaultTool) Log ¶ added in v0.1.11
func (d *DefaultTool) Log(ctx context.Context, l contract.Level, v any, prefix string, msg ...string)
Log writes a log entry, but does nothing if Client is nil.
func (*DefaultTool) Wrap ¶ added in v0.1.11
Wrap wraps a function with logging, but skips logging if Client is nil.
func (*DefaultTool) WrapHandler ¶ added in v0.1.578
func (d *DefaultTool) WrapHandler(h contract.HandlerFunc) contract.HandlerFunc
WrapHandler wraps a handler with logging, but skips logging if Client is nil.
func (*DefaultTool) WrapMiddleware ¶ added in v0.1.706
func (d *DefaultTool) WrapMiddleware(m contract.MiddlewareFunc) contract.MiddlewareFunc
WrapMiddleware araps a middleware with logging, but skips logging if Client is nil.
type Dependencies ¶ added in v0.1.8
type Dependencies struct {
M contract.Marshaler
U contract.Unmarshaler
}
type Tool ¶ added in v0.1.245
type Tool interface {
contract.LogOperator
contract.ComponentExtractor
}
Click to show internal directories.
Click to hide internal directories.