4 * Sanitizers replace data fields before logging.
5 * None are bundled, but here is an example of one.
9 * Example sanitizer function.
10 * Sanitizers are called initially with `sanitize` false, to only determine
11 * whether the data object will be changed. If so, the sanitizer is then
12 * called again with `sanitize` true, but provided with a clone of the
13 * original data to update, to avoid leaking any applied changes back to the
15 * @param {Object} data
16 * @param {Boolean} sanitize
17 * @returns {Boolean} whether sanitizer is applicable to data
19 /* istanbul ignore next */
20 function _sanitizer(data
, sanitize
= true) {
23 const sensitiveFieldLength
= data
?.sensitiveField
?.length
;
24 if (sensitiveFieldLength
) {
28 data
.sensitiveField
= '*'.repeat(sensitiveFieldLength
);