Package com.apple.foundationdb.util
Interface LoggableKeysAndValues<T extends LoggableKeysAndValues<T>>
- Type Parameters:
T
- type of object to associate loggable information with
- All Known Implementing Classes:
BunchedMapException
,BunchedSerializationException
,LoggableException
,LoggableKeysAndValuesImpl
,MoreAsyncUtil.DeadlineExceededException
,SynchronizedSessionLockedException
public interface LoggableKeysAndValues<T extends LoggableKeysAndValues<T>>
Associates loggable information with an object as a map.
Record layer log messages are (relatively) well formed. They are
comprised of a static "title" of the message along with a set of
keys and values that provide context about the "title" of the message.
For example a "File not found" log entry may include keys and values
like filename="foo" and directory="/bar". This makes the logs easy
to generally search for all such errors, later extracting the set of
files and directories that couldn't be found. This interface defines
the methods that all objects that wish to provide such logging details
must implement.
-
Method Summary
Modifier and TypeMethodDescriptionaddLogInfo
(Object... keyValue) Add a list of key/value pairs to the log information.addLogInfo
(String description, Object object) Add a key/value pair to the log information.Object[]
Export the log information to a flattened array.Get the log information associated with object as a map.
-
Method Details
-
getLogInfo
Get the log information associated with object as a map.- Returns:
- a single map with all log information
-
addLogInfo
Add a key/value pair to the log information. This will use the description given as the key and the object provided as the value.- Parameters:
description
- description of the log info pairobject
- value of the log info pair- Returns:
- this
LoggableException
-
addLogInfo
Add a list of key/value pairs to the log information. This will treat the list of items as pairs to be added with every even element being a key and every odd element being a value (associated with the even key preceding it). So, for example,["k0", "v0", "k1", "v1"]
will add two pairs to the log info, one with key"k0"
and value"v0"
and one with key"k1"
and value"v1"
. Note that this is the same format that is exported byexportLogInfo()
.- Parameters:
keyValue
- flattened map of key-value pairs- Returns:
- this
T
- Throws:
IllegalArgumentException
- ifkeyValue
has odd length
-
exportLogInfo
Export the log information to a flattened array. This will flatten the map that would be returned bygetLogInfo()
into an array where every even element is a key within the map and every odd element is the value associated with the key before it. So, for example,{"k0:"v0", "k1":"v1"}
would be flattened into["k0", "v0", "k1", "v1"]
. Note that this is the same format that is accepted byaddLogInfo(Object...)
.- Returns:
- a flattened map of key-value pairs
-