LogValueSanitizer typedef
LogValueSanitizer =
Object? Function(SanitizeContext ctx)
Handles one value on its way into the output of data.
Returning a value identical to SanitizeContext.value means "left alone". Anything else is substituted for the original: the original is not walked into, and its children are never offered to the rule. The replacement, however, renders as an ordinary value — its own children are offered to the rule like any others. Returning Sanitize.drop removes the value from the output (see Loggable.sanitizer).
It follows that a rule returning a container that holds a value which matches the same rule again will recurse forever:
// Do not do this: the replacement contains 'secret', the rule fires on
// it again, and it substitutes the container endlessly.
Loggable.sanitizer = (ctx) =>
ctx.value == 'secret' ? {'was': 'secret'} : ctx.value;
The rule must be total: an exception from it escapes into the publisher (see the spec, "Errors").
Implementation
typedef LogValueSanitizer = Object? Function(SanitizeContext ctx);