UNPKG

@sapphire/plugin-logger

Version:

Plugin for @sapphire/framework to have pretty console output

40 lines (38 loc) 1.34 kB
import { __name, __publicField } from '../chunk-2JTKI4GS.mjs'; import { LoggerStyle } from './LoggerStyle.mjs'; import { LoggerTimestamp } from './LoggerTimestamp.mjs'; 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(options.timestamp); this.infix = options.infix ?? ""; this.message = options.message === null ? null : new 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; export { LoggerLevel }; //# sourceMappingURL=LoggerLevel.mjs.map //# sourceMappingURL=LoggerLevel.mjs.map