j

package
v0.0.0-...-5d7cfac Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 8 Imported by: 54

Documentation

Overview

Package j provides abridged aliases for jettison options with some best practices built in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func C

func C(code string) errors.Option

C is an alias for jettison/errors.WithCode. Since this should only be used with sentinel errors it also clears the useless init-time stack trace allowing wrapping to add proper stack trace.

Types

type MKS

type MKS map[string]string

MKS is a multi jettison key value string option.

Usage:
  log.InfoCtx(ctx, "msg", j.MKS{"k1": "v1", "k2": "v2"})

func (MKS) ApplyToError

func (m MKS) ApplyToError(je *internal.Error)

func (MKS) ApplyToLog

func (m MKS) ApplyToLog(l *log.Entry)

func (MKS) ContextKeys

func (m MKS) ContextKeys() []models.KeyValue

type MKV

type MKV map[string]any

MKV is a multi jettison key value option with default formats of simple values or fmt.Stringer implementations. Complex values like slices, maps, structs are not printed since it is considered bad practice.

Usage:
  log.InfoCtx(ctx, "msg", j.MKV{"k1": 1, "k2": "v"})

func KS

func KS(key string, value string) MKV

KS returns a jettison key value string option.

func KV

func KV(key string, value any) MKV

KV returns a jettison key value option the with default format of a simple value or fmt.Stringer implementation. Complex values like slices, maps, structs are not printed since it is considered bad practice.

func (MKV) ApplyToError

func (m MKV) ApplyToError(je *internal.Error)

func (MKV) ApplyToLog

func (m MKV) ApplyToLog(l *log.Entry)

func (MKV) ContextKeys

func (m MKV) ContextKeys() []models.KeyValue

Jump to

Keyboard shortcuts

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