log

package
v0.1.931 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrComponentFailure  = errors.New("failed to get caller information")
	ErrJSONIndentFailure = errors.New("failed to indent data into JSON")
	ErrJSONUnmarshal     = errors.New("failed to unmarshal JSON")
	ErrFieldTruncation   = errors.New("some fields were truncated")
)

Functions

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration dynamically chooses the best unit for logging.

Types

type Blackbox

type Blackbox interface {
	// contains filtered or unexported methods
}

type Client

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

type ClientOptions struct {
	Keys   map[string]string
	MaxLen uint
}

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

func (d *DefaultTool) Wrap(ctx context.Context, fn func() (any, error)) error

Wrap wraps a function with logging, but skips logging if Client is nil.

func (*DefaultTool) WrapHandler added in v0.1.578

WrapHandler wraps a handler with logging, but skips logging if Client is nil.

func (*DefaultTool) WrapMiddleware added in v0.1.706

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 Key

type Key = string
const (
	GoogleMessageKey   Key = "message"
	GoogleSeverityKey  Key = "severity"
	GoogleTimestampKey Key = "timestamp"
	GoogleComponentKey Key = "component"
)

type Tool added in v0.1.245

Jump to

Keyboard shortcuts

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