Package net.logstash.logback.mask
Class RegexValueMasker
java.lang.Object
net.logstash.logback.mask.RegexValueMasker
- All Implemented Interfaces:
ValueMasker
Masks values based on a regular expression.
-
Constructor Summary
ConstructorDescriptionRegexValueMasker
(String regex, Object mask) RegexValueMasker
(Pattern pattern, Object mask) -
Method Summary
Modifier and TypeMethodDescriptionmask
(JsonStreamContext context, Object o) If the given value at the JSON stream context's current path should be masked, then returns the masked value to write as the value..
-
Constructor Details
-
RegexValueMasker
- Parameters:
regex
- the regex used to identify values to maskmask
- the value to write for values that match the regex (can contain back references to capture groups in the regex)
-
RegexValueMasker
- Parameters:
pattern
- the pattern used to identify values to maskmask
- the value to write for values that match the regex (can contain back references to capture groups in the regex)
-
-
Method Details
-
mask
Description copied from interface:ValueMasker
If the given value at the JSON stream context's current path should be masked, then returns the masked value to write as the value.. TheMaskingJsonGenerator
will write the returned masked value as the value (instead of the original value).If the given value at the JSON stream context's current path should NOT be masked, returns null.
- Specified by:
mask
in interfaceValueMasker
- Parameters:
context
- the current JSON stream context, which can be used to determine the path within the JSON output. (could be at a field value path or an array element value path)o
- the number or string scalar value to potentially mask (could be a field value or an array element value).- Returns:
- A non-null masked value to write if given value at the JSON stream context's current path should be masked.
Otherwise null if the given value at the JSON stream context's current path should NOT be masked.
To write a JSON null value as the masked value, return
NullNode.instance
. To write "****", the returnMaskingJsonGenerator.MASK
-