Package net.logstash.logback.argument
Class StructuredArguments
java.lang.Object
net.logstash.logback.argument.StructuredArguments
Factory for creating
StructuredArgument
s.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic StructuredArgument
Abbreviated convenience method for callingarray(String, Object...)
.static StructuredArgument
Adds a field to the JSON event whose key isfieldName
and whose value is a JSON array of objects AND a string version of the array to the formatted message.static StructuredArgument
defer
(Supplier<? extends StructuredArgument> structuredArgumentSupplier) Defer the evaluation of the argument until actually required.static StructuredArgument
Abbreviated convenience method for callingentries(Map)
.static StructuredArgument
Adds a "key":"value" entry for each Map entry to the JSON event ANDmap.toString()
to the formatted message.static StructuredArgument
Abbreviated convenience method for callingfields(Object)
.static StructuredArgument
Adds a "key":"value" entry for each field in the given object to the JSON event ANDobject.toString()
to the formatted message.static StructuredArgument
Convenience method for callingkeyValue(String, Object, String)
using theDEFAULT_KEY_VALUE_MESSAGE_FORMAT_PATTERN
.static StructuredArgument
Adds "key":"value" to the JSON event AND name/value to the formatted message using the given messageFormatPattern.static StructuredArgument
Abbreviated convenience method for callingkeyValue(String, Object)
.static StructuredArgument
Abbreviated convenience method for callingkeyValue(String, Object, String)
.static StructuredArgument
Abbreviated convenience method for callingraw(String, String)
.static StructuredArgument
Adds therawJsonValue
to the JSON event AND therawJsonValue
to the formatted message.static String
Format the argument into a string.static StructuredArgument
Abbreviated convenience method for callingvalue(String, Object)
.static StructuredArgument
Adds "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
StructuredArgument
instance - See Also:
-
kv
Abbreviated convenience method for callingkeyValue(String, Object)
.- Parameters:
key
- the key (field name)value
- the value- Returns:
- a pre-populated
StructuredArgument
instance - 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
StructuredArgument
instance - 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
StructuredArgument
instance - 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
StructuredArgument
instance - See Also:
-
v
Abbreviated convenience method for callingvalue(String, Object)
.- Parameters:
key
- the key (field name)value
- the value- Returns:
- a pre-populated
StructuredArgument
instance - See Also:
-
entries
Adds a "key":"value" entry for each Map entry to the JSON event ANDmap.toString()
to the formatted message.- Parameters:
map
-Map
holding the key/value pairs- Returns:
- a pre-populated
StructuredArgument
instance - See Also:
-
e
Abbreviated convenience method for callingentries(Map)
.- Parameters:
map
-Map
holding the key/value pairs- Returns:
- a pre-populated
StructuredArgument
instance - 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
StructuredArgument
instance - See Also:
-
f
Abbreviated convenience method for callingfields(Object)
.- Parameters:
object
- the object to write fields from- Returns:
- a pre-populated
StructuredArgument
instance - See Also:
-
array
Adds a field to the JSON event whose key isfieldName
and 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 thefieldName
key- Returns:
- a pre-populated
StructuredArgument
instance - See Also:
-
a
Abbreviated convenience method for callingarray(String, Object...)
.- Parameters:
fieldName
- field nameobjects
- elements of the array to write under thefieldName
key- Returns:
- a pre-populated
StructuredArgument
instance - See Also:
-
raw
Adds therawJsonValue
to the JSON event AND therawJsonValue
to the formatted message.- Parameters:
fieldName
- field namerawJsonValue
- the raw JSON value- Returns:
- a pre-populated
StructuredArgument
instance - See Also:
-
r
Abbreviated convenience method for callingraw(String, String)
.- Parameters:
fieldName
- field namerawJsonValue
- the raw JSON value- Returns:
- a pre-populated
StructuredArgument
instance - 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
StructuredArgument
instance - 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
-