From a384a36643b2c4f71d5adc28a5bee5aab8151c49 Mon Sep 17 00:00:00 2001 From: Clint Armstrong Date: Sun, 1 Oct 2023 20:05:17 -0400 Subject: [PATCH] Add Type function to context --- context.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/context.go b/context.go index fc62ad9c..9efbdc67 100644 --- a/context.go +++ b/context.go @@ -379,6 +379,12 @@ func (c Context) Interface(key string, i interface{}) Context { return c } +// Type adds the field key with val's type using reflection. +func (c Context) Type(key string, val interface{}) Context { + c.l.context = enc.AppendType(enc.AppendKey(c.l.context, key), val) + return c +} + // Any is a wrapper around Context.Interface. func (c Context) Any(key string, i interface{}) Context { return c.Interface(key, i)