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 */
22 * @param {object} data data object to mogrify
23 * @param {boolean} sanitize mogrify if truue
24 * @returns {boolean} whether data would be mogrified
26 function _sanitizer(data
, sanitize
= true) {
29 const sensitiveFieldLength
= data
?.sensitiveField
?.length
;
30 if (sensitiveFieldLength
) {
34 data
.sensitiveField
= '*'.repeat(sensitiveFieldLength
);