@visulima/pail
Version:
Highly configurable Logger for Node.js, Edge and Browser.
27 lines (25 loc) • 908 B
JavaScript
import __cjs_mod__ from "node:module"; // -- packem CommonJS require shim --
const require = __cjs_mod__.createRequire(import.meta.url);
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
class RedactProcessor {
static {
__name(this, "RedactProcessor");
}
#redact;
constructor(rules, options) {
try {
const { redact, standardRules } = require("@visulima/redact");
this.#redact = (input) => redact(input, rules || standardRules, options);
} catch {
throw new Error("The '@visulima/redact' package is missing. Make sure to install the '@visulima/redact' package.");
}
}
process(meta) {
meta.message = this.#redact(meta.message);
meta.context = this.#redact(meta.context);
meta.error = this.#redact(meta.error);
return meta;
}
}
export { RedactProcessor as default };