Documentation ¶
Index ¶
- Variables
- func WithContextFields(ctx context.Context, fields ...Field) context.Context
- type Field
- func Any(key string, value any) Field
- func Bool(key string, value bool) Field
- func Error(err error) Field
- func Float[T floats](key string, value T) Field
- func Int[T integers](key string, value T) Field
- func JSONEscape(key string, value []byte) Field
- func JSONEscapeSecure(key string, value []byte) Field
- func String(key string, value string) Field
- type Fields
Constants ¶
This section is empty.
Variables ¶
var ContextLogFields = struct{}{}
Functions ¶
Types ¶
type Field ¶
Field stores key-value pairs in order to map them into log structure. TODO(Gorkovets Roman): Make Value field for al supported types in order to avoid inappropriate use of any.
func JSONEscape ¶ added in v1.0.13
JSONEscape used for storing json string with escaping characters.
func JSONEscapeSecure ¶ added in v1.0.13
JSONEscapeSecure the same as JSONEscape but also masks the key-value pairs specified in config. Example:
Data = `{\"password\": \"qwerty123\", \"email\": \"example@example.com\"}`
Using PASSWORD label for "password" and EMAIL for "email" we will reach the next result:
Output = `{\"password\": \"*********\", \"email\": \"e******@example.com\"}`
type Fields ¶
type Fields []Field
Fields alias for []Field as it's more comfortable to use it this way
func FieldsFromCtx ¶
FieldsFromCtx extract fields from context. If ctx is nil, use context.Background()