logging

package
v0.2.0-rc.8 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextAttrs

func ContextAttrs(ctx context.Context) []slog.Attr

ContextAttrs returns standard correlation attributes from context.

func ErrorAttr

func ErrorAttr(err error) slog.Attr

ErrorAttr adds classification fields to a log call with other attributes.

func ErrorAttrs

func ErrorAttrs(err error) []slog.Attr

ErrorAttrs returns bounded classifications without formatting the error.

func HTTPMiddleware

func HTTPMiddleware(logger *slog.Logger, logRequests bool) fiber.Handler

HTTPMiddleware returns a Fiber middleware that logs HTTP request metadata.

func LogError

func LogError(ctx context.Context, message string, err error)

LogError records a safe error diagnostic with the process logger.

func LogErrorWith

func LogErrorWith(ctx context.Context, logger *slog.Logger, message string, err error)

LogErrorWith records a safe error diagnostic with the supplied logger.

func LogMethodCompletion

func LogMethodCompletion(ctx context.Context, logger *slog.Logger, completion MethodCompletion)

LogMethodCompletion logs one method completion event for generated decorators.

func Setup

func Setup(cfg Config, component string) (*slog.Logger, io.Closer, error)

Setup creates a logger with file rotation and stdout output

func WithAttrs

func WithAttrs(ctx context.Context, attrs ...slog.Attr) context.Context

WithAttrs attaches allowlisted log attributes to ctx.

Types

type Config

type Config struct {
	Level            string
	FilePath         string
	RotationInterval time.Duration
	MaxFileSizeMB    int
	Environment      string
	OTLPLogsEndpoint string
	HandleSDKErrors  bool
}

Config contains logging configuration

type MethodCompletion

type MethodCompletion struct {
	Layer       string
	Package     string
	Interface   string
	Method      string
	StartedAt   time.Time
	CompletedAt time.Time
	Err         error
}

MethodCompletion describes one completed decorated interface method call.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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