Documentation
¶
Index ¶
- func BuildAttributes(ctx context.Context, r *http.Request, ...) []interface{}
- func DefaultExtractor(ctx context.Context, r *http.Request) map[string]interface{}
- func GetLogger(ctx context.Context) *log.Logger
- func New(logger log.Logger, extractFunction ExtractFunction) mux.MiddlewareFunc
- func WithLogger(ctx context.Context, logger *log.Logger) context.Context
- type ExtractFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAttributes ¶
func BuildAttributes(ctx context.Context, r *http.Request, extractFunc func(ctx context.Context, r *http.Request) map[string]interface{}) []interface{}
Headers and extra attributes are json.Marshaled, but if that fails, the headers are sent to kusto as the original map[string]string The function logs to CtxLog to notify users of the error if they wish to fix it
func DefaultExtractor ¶
DefaultExtractor extracts operation request fields from the context. It returns the filtered map containing only the specified keys.
func New ¶
func New(logger log.Logger, extractFunction ExtractFunction) mux.MiddlewareFunc
New creates a context logging middleware. Parameters
logger: A slog.Logger instance used for logging. Any static attributes added to this logger before passing it in will be preserved extractFunction: ExtractFunction extracts information from the ctx and/or the request and put it in the logger
Types ¶
Click to show internal directories.
Click to hide internal directories.