UNPKG

@sapphire/plugin-logger

Version:

Plugin for @sapphire/framework to have pretty console output

47 lines (45 loc) 1.5 kB
import { __name, __publicField } from '../chunk-2JTKI4GS.mjs'; import { Timestamp } from '@sapphire/timestamp'; import { LoggerStyle } from './LoggerStyle.mjs'; var _LoggerTimestamp = class _LoggerTimestamp { constructor(options = {}) { /** * The timestamp used to format the current date. * @since 1.0.0 */ __publicField(this, "timestamp"); /** * Whether or not the logger will show a timestamp in UTC. * @since 1.0.0 */ __publicField(this, "utc"); /** * The logger style to apply the color to the timestamp. * @since 1.0.0 */ __publicField(this, "color"); /** * The final formatter. * @since 1.0.0 */ __publicField(this, "formatter"); this.timestamp = new Timestamp(options.pattern ?? "YYYY-MM-DD HH:mm:ss"); this.utc = options.utc ?? false; this.color = options.color === null ? null : new LoggerStyle(options.color); this.formatter = options.formatter ?? ((timestamp) => `${timestamp} - `); } /** * Formats the current time. * @since 1.0.0 */ run() { const date = /* @__PURE__ */ new Date(); const result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date); return this.formatter(this.color ? this.color.run(result) : result); } }; __name(_LoggerTimestamp, "LoggerTimestamp"); var LoggerTimestamp = _LoggerTimestamp; export { LoggerTimestamp }; //# sourceMappingURL=LoggerTimestamp.mjs.map //# sourceMappingURL=LoggerTimestamp.mjs.map