@ayanaware/logger
Version:
Useful and great looking logging made easy
27 lines • 857 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Formatter = void 0;
const util_1 = require("util");
const LogMeta_1 = require("../LogMeta");
class Formatter {
format(meta) {
const formatterMap = meta[LogMeta_1.LOG_META_FORMATTER_MAP_SYMBOL];
if (formatterMap.has(this)) {
return formatterMap.get(this);
}
let msg;
if (meta.input instanceof Error) {
msg = this.formatError(meta, meta.input);
}
else if (typeof meta.input != 'string') {
msg = this.formatMessage(meta, (0, util_1.inspect)(meta.input));
}
else {
msg = this.formatMessage(meta, meta.input);
}
formatterMap.set(this, msg);
return msg;
}
}
exports.Formatter = Formatter;
//# sourceMappingURL=Formatter.js.map