ctxlog

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ctxlog allows logging data stored with a context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFunc

func AddFunc(ctx context.Context, f CtxKVFunc) context.Context

AddFunc associates a new CtxKVFunc function to a context.

func Logger

func Logger(ctx context.Context, logger log.Logger) log.Logger

Logger runs the associated CtxKVFunc functions and returns a new logger with the results.

Types

type CtxKVFunc

type CtxKVFunc func(context.Context) []interface{}

CtxKVFunc creates logger key-value pairs from a context. CtxKVFuncs should aim to be be as efficient as possible—ideally only doing the minimum to read context values and generate KV pairs. Each associated CtxKVFunc is called every time we adapt a logger with Logger.

func SimpleStringFunc

func SimpleStringFunc(logKey string, ctxKey interface{}) CtxKVFunc

SimpleStringFunc is a helper that generates a simple CtxKVFunc that returns a key-value pair if found on the context.

Jump to

Keyboard shortcuts

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