Class StructuredArguments
java.lang.Object
software.amazon.lambda.powertools.logging.argument.StructuredArguments
Factory for creating
StructuredArguments.
Inspired from the StructuredArgument of logstash-logback-encoder.-
Method Summary
Modifier and TypeMethodDescriptionstatic StructuredArgumentAdds a field to the JSON structure with key as the key and where value is a JSON array of objects AND a string version of the array to the formatted message:"key": [value, value]Returns null if the key is a reserved key.static StructuredArgumentAdds a "key": "value" to the JSON structure for each entry in the map andmap.toString()to the formatted message.static StructuredArgumentAdds "key": "value" to the JSON structure and "key=value" to the formatted message.static StructuredArgumentAdds therawJsonto the JSON structure and therawJsonto the formatted message.static StringFormat the argument into a string.
-
Method Details
-
entry
Adds "key": "value" to the JSON structure and "key=value" to the formatted message. Returns null if the key is a reserved key.- Parameters:
key- the field namevalue- the value associated with the key (can be any kind of object)- Returns:
- a
StructuredArgumentpopulated with the data, or null if key is reserved
-
entries
Adds a "key": "value" to the JSON structure for each entry in the map andmap.toString()to the formatted message. If the map contains any reserved keys, those entries will be filtered out.- Parameters:
map-Mapholding the key/value pairs- Returns:
- a
MapArgumentpopulated with the data, with reserved keys filtered out
-
array
Adds a field to the JSON structure with key as the key and where value is a JSON array of objects AND a string version of the array to the formatted message:"key": [value, value]Returns null if the key is a reserved key.- Parameters:
key- the field namevalues- elements of the array associated with the key- Returns:
- an
ArrayArgumentpopulated with the data, or null if key is reserved
-
json
Adds therawJsonto the JSON structure and therawJsonto the formatted message. Returns null if the key is a reserved key.- Parameters:
key- the field namerawJson- the raw JSON String- Returns:
- a
JsonArgumentpopulated with the data, or null if key is reserved
-
toString
Format the argument into a string. This method mimics the slf4j behavior: array objects are formatted as array usingArrays.toString(long[]), non array object usingString.valueOf(java.lang.Object).See org.slf4j.helpers.MessageFormatter#deeplyAppendParameter(StringBuilder, Object, Map)}
- Parameters:
arg- the argument to format- Returns:
- formatted string version of the argument
-