Class ContextPairs
java.lang.Object
org.springframework.boot.logging.structured.ContextPairs
Helper that can be used to add JSON pairs from context data (typically the logger MDC)
in the correct location (or drop them altogether).
- Since:
- 3.5.0
- Author:
- Phillip Webb
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescription<T> BiConsumer<T,
BiConsumer<String, Object>> flat
(String delimeter, Consumer<ContextPairs.Pairs<T>> pairs) Add pairs using flat naming.<T> BiConsumer<T,
BiConsumer<String, Object>> flat
(BinaryOperator<String> joiner, Consumer<ContextPairs.Pairs<T>> pairs) Add pairs using flat naming.<T> BiConsumer<T,
BiConsumer<String, Object>> nested
(Consumer<ContextPairs.Pairs<T>> pairs) Add pairs using nested naming (for example as used in ECS).
-
Method Details
-
flat
public <T> BiConsumer<T,BiConsumer<String, flatObject>> (String delimeter, Consumer<ContextPairs.Pairs<T>> pairs) Add pairs using flat naming.- Type Parameters:
T
- the item type- Parameters:
delimeter
- the delimiter used if there is a prefixpairs
- callback to add all the pairs- Returns:
- a
BiConsumer
for use with theJsonWriter
-
flat
public <T> BiConsumer<T,BiConsumer<String, flatObject>> (BinaryOperator<String> joiner, Consumer<ContextPairs.Pairs<T>> pairs) Add pairs using flat naming.- Type Parameters:
T
- the item type- Parameters:
joiner
- the function used to join the prefix and namepairs
- callback to add all the pairs- Returns:
- a
BiConsumer
for use with theJsonWriter
-
nested
Add pairs using nested naming (for example as used in ECS).- Type Parameters:
T
- the item type- Parameters:
pairs
- callback to add all the pairs- Returns:
- a
BiConsumer
for use with theJsonWriter
-