You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logtags stores the provided key/value pairs into an object of type
Buffer, then uses Go's standard context.WithValue to attach the
buffer.
An instance of Buffer inside a context is immutable. When adding a
new k/v pair to a context that already carries a Buffer, a new one
is created with all previous k/v pair, and the new k/v pair is added
to that.
The FromContext() function retrieves the topmost (most recent)
Buffer.
Advanced uses:
To add multiple k/v pairs in one go, without using quadratic space in
Buffer instances:
manually instantiate a Buffer.
use func (*Buffer) Add(key string, value interface{}) to populate the buffer.
use func AddTags(ctx context.Context, tags *Buffer) context.Context to embark
all the k/v pairs at once.
To format all the contained k/v pairs in a Buffer, use its
String() or FormatToString(*strings.Builder) methods:
when the value part is nil, only the key is displayed.
when the value part is non-nil, and the key is just one character
long, the key and value are concatenated for display. This enables e.g.
printing k="n", v=123 as n123.
otherwise, the key and value are printed with = as separator.