Package net.logstash.logback.mask
Class FieldNameBasedFieldMasker
java.lang.Object
net.logstash.logback.mask.FieldNameBasedFieldMasker
- All Implemented Interfaces:
FieldMasker
Masks values of specific JSON field names within a JSON stream.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionmask
(JsonStreamContext context) If the field at the JSON stream context's current path should be masked, then returns the masked value to write as the field's value.
-
Constructor Details
-
FieldNameBasedFieldMasker
- Parameters:
fieldNamesToMask
- the names of fields in the JSON stream to maskmask
- the value to write for fields in the fieldNamesToMask
-
-
Method Details
-
mask
Description copied from interface:FieldMasker
If the field at the JSON stream context's current path should be masked, then returns the masked value to write as the field's value. TheMaskingJsonGenerator
will write the returned masked value as the field's value (instead of the original field's value).If the JSON stream context's current path should NOT be masked, returns null.
- Specified by:
mask
in interfaceFieldMasker
- Parameters:
context
- the current JSON stream context, which can be used to determine the path within the JSON output.- Returns:
- A non-null masked value to write if the current field should be masked.
Otherwise null if the current field should not be masked.
To write a JSON null value as the masked value, return
NullNode.instance
. To write "****", the returnMaskingJsonGenerator.MASK
-