logger

package
v0.0.0-...-e38db06 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
)

Variables

View Source
var AttrKey = AttrKeys{
	App: AppAttrKeys{
		Name:    "name",
		Version: "version",
	},
	HTTP: HTTPAttrKeys{
		Body:     "body",
		BodySize: "body_size",
		Headers:  "headers",
		Method:   "method",
		Path:     "path",
		Status:   "status",
	},
	IP:           "ip",
	PID:          "pid",
	ResponseTime: "response_time",
	Tags:         "tags",
}

Functions

This section is empty.

Types

type AppAttrKeys

type AppAttrKeys struct {
	Name    string
	Version string
}

type AttrKeys

type AttrKeys struct {
	App          AppAttrKeys
	HTTP         HTTPAttrKeys
	IP           string
	PID          string
	ResponseTime string
	Tags         string
}

type CustomLogger

type CustomLogger struct {
	Enabled bool
	Level   string
	Log     *slog.Logger
}

CustomLogger encapsulates a logger with an associated log level and toggle

func (*CustomLogger) CreateContextLogger

func (l *CustomLogger) CreateContextLogger(traceID string) *slog.Logger

CreateContextLogger returns a new child logger with attached trace ID

type DevHandler

type DevHandler struct {
	// contains filtered or unexported fields
}

func NewDevHandler

func NewDevHandler(meta app.Metadata, opts *slog.HandlerOptions) *DevHandler

func (*DevHandler) Enabled

func (h *DevHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*DevHandler) Handle

func (h *DevHandler) Handle(ctx context.Context, r slog.Record) error

func (*DevHandler) WithAttrs

func (h *DevHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*DevHandler) WithGroup

func (h *DevHandler) WithGroup(name string) slog.Handler

type HTTPAttrKeys

type HTTPAttrKeys struct {
	Body     string
	BodySize string
	Headers  string
	Method   string
	Path     string
	Status   string
}

Jump to

Keyboard shortcuts

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