java.lang.Object
net.logstash.logback.argument.StructuredArguments
Factory for creating
StructuredArguments.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StructuredArgumentAbbreviated convenience method for callingarray(String, Object...).static StructuredArgumentAdds a field to the JSON event whose key isfieldNameand whose value is a JSON array of objects AND a string version of the array to the formatted message.static StructuredArgumentdefer(Supplier<? extends StructuredArgument> structuredArgumentSupplier) Defer the evaluation of the argument until actually required.static StructuredArgumentAbbreviated convenience method for callingentries(Map).static StructuredArgumentAdds a "key":"value" entry for each Map entry to the JSON event ANDmap.toString()to the formatted message.static StructuredArgumentAbbreviated convenience method for callingfields(Object).static StructuredArgumentAdds a "key":"value" entry for each field in the given object to the JSON event ANDobject.toString()to the formatted message.static StructuredArgumentConvenience method for callingkeyValue(String, Object, String)using theDEFAULT_KEY_VALUE_MESSAGE_FORMAT_PATTERN.static StructuredArgumentAdds "key":"value" to the JSON event AND name/value to the formatted message using the given messageFormatPattern.static StructuredArgumentAbbreviated convenience method for callingkeyValue(String, Object).static StructuredArgumentAbbreviated convenience method for callingkeyValue(String, Object, String).static StructuredArgumentAbbreviated convenience method for callingraw(String, String).static StructuredArgumentAdds therawJsonValueto the JSON event AND therawJsonValueto the formatted message.static StringFormat the argument into a string.static StructuredArgumentAbbreviated convenience method for callingvalue(String, Object).static StructuredArgumentAdds "key":"value" to the JSON event AND value to the formatted message (without the key).
-
Field Details
-
DEFAULT_KEY_VALUE_MESSAGE_FORMAT_PATTERN
The default message format used when writing key value pairs to the log message.- See Also:
-
VALUE_ONLY_MESSAGE_FORMAT_PATTERN
A message format pattern that will only write the argument value to a log message (i.e. it won't write the key).- See Also:
-
-
Method Details
-
keyValue
Convenience method for callingkeyValue(String, Object, String)using theDEFAULT_KEY_VALUE_MESSAGE_FORMAT_PATTERN.Basically, adds "key":"value" to the JSON event AND name=value to the formatted message.
- Parameters:
key- the key (field name)value- the value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
kv
Abbreviated convenience method for callingkeyValue(String, Object).- Parameters:
key- the key (field name)value- the value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
keyValue
Adds "key":"value" to the JSON event AND name/value to the formatted message using the given messageFormatPattern.- Parameters:
key- the key (field name)value- the valuemessageFormatPattern- the pattern used to concatenate the key and the value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
kv
Abbreviated convenience method for callingkeyValue(String, Object, String).- Parameters:
key- the key (field name)value- the valuemessageFormatPattern- the pattern used to concatenate the key and the value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
value
Adds "key":"value" to the JSON event AND value to the formatted message (without the key).- Parameters:
key- the key (field name)value- the value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
v
Abbreviated convenience method for callingvalue(String, Object).- Parameters:
key- the key (field name)value- the value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
entries
Adds a "key":"value" entry for each Map entry to the JSON event ANDmap.toString()to the formatted message.- Parameters:
map-Mapholding the key/value pairs- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
e
Abbreviated convenience method for callingentries(Map).- Parameters:
map-Mapholding the key/value pairs- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
fields
Adds a "key":"value" entry for each field in the given object to the JSON event ANDobject.toString()to the formatted message.- Parameters:
object- the object to write fields from- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
f
Abbreviated convenience method for callingfields(Object).- Parameters:
object- the object to write fields from- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
array
Adds a field to the JSON event whose key isfieldNameand whose value is a JSON array of objects AND a string version of the array to the formatted message.- Parameters:
fieldName- field nameobjects- elements of the array to write under thefieldNamekey- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
a
Abbreviated convenience method for callingarray(String, Object...).- Parameters:
fieldName- field nameobjects- elements of the array to write under thefieldNamekey- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
raw
Adds therawJsonValueto the JSON event AND therawJsonValueto the formatted message.- Parameters:
fieldName- field namerawJsonValue- the raw JSON value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
r
Abbreviated convenience method for callingraw(String, String).- Parameters:
fieldName- field namerawJsonValue- the raw JSON value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
defer
public static StructuredArgument defer(Supplier<? extends StructuredArgument> structuredArgumentSupplier) Defer the evaluation of the argument until actually required.- Parameters:
structuredArgumentSupplier- a supplier for the argument value- Returns:
- a pre-populated
StructuredArgumentinstance - See Also:
-
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
-