UNPKG

@sapphire/plugin-logger

Version:

Plugin for @sapphire/framework to have pretty console output

45 lines (42 loc) 1.75 kB
'use strict'; var LoggerStyle_cjs = require('./LoggerStyle.cjs'); var LoggerTimestamp_cjs = require('./LoggerTimestamp.cjs'); var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); var _LoggerLevel = class _LoggerLevel { constructor(options = {}) { /** * The timestamp formatter. * @since 1.0.0 */ __publicField(this, "timestamp"); /** * The infix, added between the timestamp and the message. * @since 1.0.0 */ __publicField(this, "infix"); /** * The style formatter for the message. * @since 1.0.0 */ __publicField(this, "message"); this.timestamp = options.timestamp === null ? null : new LoggerTimestamp_cjs.LoggerTimestamp(options.timestamp); this.infix = options.infix ?? ""; this.message = options.message === null ? null : new LoggerStyle_cjs.LoggerStyle(options.message); } run(content) { const prefix = (this.timestamp?.run() ?? "") + this.infix; if (prefix.length) { const formatter = this.message ? (line) => prefix + this.message.run(line) : (line) => prefix + line; return content.split("\n").map(formatter).join("\n"); } return this.message ? this.message.run(content) : content; } }; __name(_LoggerLevel, "LoggerLevel"); var LoggerLevel = _LoggerLevel; exports.LoggerLevel = LoggerLevel; //# sourceMappingURL=LoggerLevel.cjs.map //# sourceMappingURL=LoggerLevel.cjs.map