@sapphire/plugin-logger 3.0.8-next.eccc557.0 → 4.0.0-pr-512.86f3d06.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cjs/index.cjs +37 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.ts +383 -0
  4. package/dist/cjs/lib/Logger.cjs +101 -0
  5. package/dist/cjs/lib/Logger.cjs.map +1 -0
  6. package/dist/cjs/lib/LoggerLevel.cjs +48 -0
  7. package/dist/cjs/lib/LoggerLevel.cjs.map +1 -0
  8. package/dist/cjs/lib/LoggerStyle.cjs +115 -0
  9. package/dist/cjs/lib/LoggerStyle.cjs.map +1 -0
  10. package/dist/cjs/lib/LoggerTimestamp.cjs +55 -0
  11. package/dist/cjs/lib/LoggerTimestamp.cjs.map +1 -0
  12. package/dist/cjs/register.cjs +23 -0
  13. package/dist/cjs/register.cjs.map +1 -0
  14. package/dist/{register.d.ts → cjs/register.d.ts} +6 -4
  15. package/dist/esm/chunk-6QB3UK4Q.mjs +11 -0
  16. package/dist/esm/chunk-6QB3UK4Q.mjs.map +1 -0
  17. package/dist/esm/index.d.mts +383 -0
  18. package/dist/esm/index.mjs +11 -0
  19. package/dist/esm/index.mjs.map +1 -0
  20. package/dist/esm/lib/Logger.mjs +93 -0
  21. package/dist/esm/lib/Logger.mjs.map +1 -0
  22. package/dist/esm/lib/LoggerLevel.mjs +40 -0
  23. package/dist/esm/lib/LoggerLevel.mjs.map +1 -0
  24. package/dist/esm/lib/LoggerStyle.mjs +84 -0
  25. package/dist/esm/lib/LoggerStyle.mjs.map +1 -0
  26. package/dist/esm/lib/LoggerTimestamp.mjs +47 -0
  27. package/dist/esm/lib/LoggerTimestamp.mjs.map +1 -0
  28. package/dist/esm/register.d.mts +19 -0
  29. package/dist/esm/register.mjs +20 -0
  30. package/dist/esm/register.mjs.map +1 -0
  31. package/package.json +34 -18
  32. package/dist/index.d.ts +0 -10
  33. package/dist/index.d.ts.map +0 -1
  34. package/dist/index.js +0 -21
  35. package/dist/index.js.map +0 -1
  36. package/dist/index.mjs +0 -10
  37. package/dist/lib/Logger.d.ts +0 -142
  38. package/dist/lib/Logger.d.ts.map +0 -1
  39. package/dist/lib/Logger.js +0 -114
  40. package/dist/lib/Logger.js.map +0 -1
  41. package/dist/lib/LoggerLevel.d.ts +0 -50
  42. package/dist/lib/LoggerLevel.d.ts.map +0 -1
  43. package/dist/lib/LoggerLevel.js +0 -58
  44. package/dist/lib/LoggerLevel.js.map +0 -1
  45. package/dist/lib/LoggerStyle.d.ts +0 -102
  46. package/dist/lib/LoggerStyle.d.ts.map +0 -1
  47. package/dist/lib/LoggerStyle.js +0 -130
  48. package/dist/lib/LoggerStyle.js.map +0 -1
  49. package/dist/lib/LoggerTimestamp.d.ts +0 -81
  50. package/dist/lib/LoggerTimestamp.d.ts.map +0 -1
  51. package/dist/lib/LoggerTimestamp.js +0 -68
  52. package/dist/lib/LoggerTimestamp.js.map +0 -1
  53. package/dist/register.d.ts.map +0 -1
  54. package/dist/register.js +0 -20
  55. package/dist/register.js.map +0 -1
  56. package/dist/register.mjs +0 -4
@@ -0,0 +1,115 @@
1
+ 'use strict';
2
+
3
+ var Colorette = require('colorette');
4
+
5
+ function _interopNamespace(e) {
6
+ if (e && e.__esModule) return e;
7
+ var n = Object.create(null);
8
+ if (e) {
9
+ Object.keys(e).forEach(function (k) {
10
+ if (k !== 'default') {
11
+ var d = Object.getOwnPropertyDescriptor(e, k);
12
+ Object.defineProperty(n, k, d.get ? d : {
13
+ enumerable: true,
14
+ get: function () { return e[k]; }
15
+ });
16
+ }
17
+ });
18
+ }
19
+ n.default = e;
20
+ return Object.freeze(n);
21
+ }
22
+
23
+ var Colorette__namespace = /*#__PURE__*/_interopNamespace(Colorette);
24
+
25
+ var __defProp = Object.defineProperty;
26
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
27
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
28
+ var __publicField = (obj, key, value) => {
29
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
30
+ return value;
31
+ };
32
+ var _LoggerStyle = class _LoggerStyle {
33
+ constructor(resolvable = {}) {
34
+ __publicField(this, "style");
35
+ if (typeof resolvable === "function") {
36
+ this.style = resolvable;
37
+ } else {
38
+ const styles = [];
39
+ if (resolvable.effects)
40
+ styles.push(...resolvable.effects.map((text) => Colorette__namespace[text]));
41
+ if (resolvable.text)
42
+ styles.push(Colorette__namespace[resolvable.text]);
43
+ if (resolvable.background)
44
+ styles.push(Colorette__namespace[resolvable.background]);
45
+ this.style = styles.length ? styles.length === 1 ? styles[0] : (string) => styles.reduce((out, style) => style(out), string) : Colorette__namespace.reset;
46
+ }
47
+ }
48
+ /**
49
+ * Applies the style to a string.
50
+ * @since 1.0.0
51
+ * @param string The value to apply the style to.
52
+ */
53
+ run(string) {
54
+ return this.style(string);
55
+ }
56
+ };
57
+ __name(_LoggerStyle, "LoggerStyle");
58
+ var LoggerStyle = _LoggerStyle;
59
+ var LoggerStyleEffect = /* @__PURE__ */ ((LoggerStyleEffect2) => {
60
+ LoggerStyleEffect2["Reset"] = "reset";
61
+ LoggerStyleEffect2["Bold"] = "bold";
62
+ LoggerStyleEffect2["Dim"] = "dim";
63
+ LoggerStyleEffect2["Italic"] = "italic";
64
+ LoggerStyleEffect2["Underline"] = "underline";
65
+ LoggerStyleEffect2["Inverse"] = "inverse";
66
+ LoggerStyleEffect2["Hidden"] = "hidden";
67
+ LoggerStyleEffect2["Strikethrough"] = "strikethrough";
68
+ return LoggerStyleEffect2;
69
+ })(LoggerStyleEffect || {});
70
+ var LoggerStyleText = /* @__PURE__ */ ((LoggerStyleText2) => {
71
+ LoggerStyleText2["Black"] = "black";
72
+ LoggerStyleText2["Red"] = "red";
73
+ LoggerStyleText2["Green"] = "green";
74
+ LoggerStyleText2["Yellow"] = "yellow";
75
+ LoggerStyleText2["Blue"] = "blue";
76
+ LoggerStyleText2["Magenta"] = "magenta";
77
+ LoggerStyleText2["Cyan"] = "cyan";
78
+ LoggerStyleText2["White"] = "white";
79
+ LoggerStyleText2["Gray"] = "gray";
80
+ LoggerStyleText2["BlackBright"] = "blackBright";
81
+ LoggerStyleText2["RedBright"] = "redBright";
82
+ LoggerStyleText2["GreenBright"] = "greenBright";
83
+ LoggerStyleText2["YellowBright"] = "yellowBright";
84
+ LoggerStyleText2["BlueBright"] = "blueBright";
85
+ LoggerStyleText2["MagentaBright"] = "magentaBright";
86
+ LoggerStyleText2["CyanBright"] = "cyanBright";
87
+ LoggerStyleText2["WhiteBright"] = "whiteBright";
88
+ return LoggerStyleText2;
89
+ })(LoggerStyleText || {});
90
+ var LoggerStyleBackground = /* @__PURE__ */ ((LoggerStyleBackground2) => {
91
+ LoggerStyleBackground2["Black"] = "bgBlack";
92
+ LoggerStyleBackground2["Red"] = "bgRed";
93
+ LoggerStyleBackground2["Green"] = "bgGreen";
94
+ LoggerStyleBackground2["Yellow"] = "bgYellow";
95
+ LoggerStyleBackground2["Blue"] = "bgBlue";
96
+ LoggerStyleBackground2["Magenta"] = "bgMagenta";
97
+ LoggerStyleBackground2["Cyan"] = "bgCyan";
98
+ LoggerStyleBackground2["White"] = "bgWhite";
99
+ LoggerStyleBackground2["BlackBright"] = "bgBlackBright";
100
+ LoggerStyleBackground2["RedBright"] = "bgRedBright";
101
+ LoggerStyleBackground2["GreenBright"] = "bgGreenBright";
102
+ LoggerStyleBackground2["YellowBright"] = "bgYellowBright";
103
+ LoggerStyleBackground2["BlueBright"] = "bgBlueBright";
104
+ LoggerStyleBackground2["MagentaBright"] = "bgMagentaBright";
105
+ LoggerStyleBackground2["CyanBright"] = "bgCyanBright";
106
+ LoggerStyleBackground2["WhiteBright"] = "bgWhiteBright";
107
+ return LoggerStyleBackground2;
108
+ })(LoggerStyleBackground || {});
109
+
110
+ exports.LoggerStyle = LoggerStyle;
111
+ exports.LoggerStyleBackground = LoggerStyleBackground;
112
+ exports.LoggerStyleEffect = LoggerStyleEffect;
113
+ exports.LoggerStyleText = LoggerStyleText;
114
+ //# sourceMappingURL=out.js.map
115
+ //# sourceMappingURL=LoggerStyle.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/LoggerStyle.ts"],"names":["LoggerStyleEffect","LoggerStyleText","LoggerStyleBackground"],"mappings":";;;;;;;;;AAAA,YAAY,eAAe;AAMpB,IAAM,eAAN,MAAM,aAAY;AAAA,EAGjB,YAAY,aAAoC,CAAC,GAAG;AAF3D,wBAAgB;AAGf,QAAI,OAAO,eAAe,YAAY;AACrC,WAAK,QAAQ;AAAA,IACd,OAAO;AACN,YAAM,SAA4B,CAAC;AACnC,UAAI,WAAW;AAAS,eAAO,KAAK,GAAG,WAAW,QAAQ,IAAI,CAAC,SAAS,UAAU,IAAI,CAAC,CAAC;AACxF,UAAI,WAAW;AAAM,eAAO,KAAK,UAAU,WAAW,IAAI,CAAC;AAC3D,UAAI,WAAW;AAAY,eAAO,KAAK,UAAU,WAAW,UAAU,CAAC;AAEvE,WAAK,QAAQ,OAAO,SACjB,OAAO,WAAW,IACjB,OAAO,CAAC,IACR,CAAC,WAAW,OAAO,OAAO,CAAC,KAAK,UAAU,MAAM,GAAG,GAAG,MAAM,IACnD;AAAA,IACd;AAAA,EACD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOO,IAAI,QAAyB;AACnC,WAAO,KAAK,MAAM,MAAM;AAAA,EACzB;AACD;AA5ByB;AAAlB,IAAM,cAAN;AAiEA,IAAK,oBAAL,kBAAKA,uBAAL;AACN,EAAAA,mBAAA,WAAQ;AACR,EAAAA,mBAAA,UAAO;AACP,EAAAA,mBAAA,SAAM;AACN,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,eAAY;AACZ,EAAAA,mBAAA,aAAU;AACV,EAAAA,mBAAA,YAAS;AACT,EAAAA,mBAAA,mBAAgB;AARL,SAAAA;AAAA,GAAA;AAeL,IAAK,kBAAL,kBAAKC,qBAAL;AACN,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,SAAM;AACN,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AACT,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,aAAU;AACV,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,iBAAc;AACd,EAAAA,iBAAA,eAAY;AACZ,EAAAA,iBAAA,iBAAc;AACd,EAAAA,iBAAA,kBAAe;AACf,EAAAA,iBAAA,gBAAa;AACb,EAAAA,iBAAA,mBAAgB;AAChB,EAAAA,iBAAA,gBAAa;AACb,EAAAA,iBAAA,iBAAc;AAjBH,SAAAA;AAAA,GAAA;AAwBL,IAAK,wBAAL,kBAAKC,2BAAL;AACN,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,SAAM;AACN,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,YAAS;AACT,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,aAAU;AACV,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,WAAQ;AACR,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,eAAY;AACZ,EAAAA,uBAAA,iBAAc;AACd,EAAAA,uBAAA,kBAAe;AACf,EAAAA,uBAAA,gBAAa;AACb,EAAAA,uBAAA,mBAAgB;AAChB,EAAAA,uBAAA,gBAAa;AACb,EAAAA,uBAAA,iBAAc;AAhBH,SAAAA;AAAA,GAAA","sourcesContent":["import * as Colorette from 'colorette';\n\n/**\n * Logger utility that applies a style to a string.\n * @since 1.0.0\n */\nexport class LoggerStyle {\n\tpublic readonly style: Colorette.Color;\n\n\tpublic constructor(resolvable: LoggerStyleResolvable = {}) {\n\t\tif (typeof resolvable === 'function') {\n\t\t\tthis.style = resolvable;\n\t\t} else {\n\t\t\tconst styles: Colorette.Color[] = [];\n\t\t\tif (resolvable.effects) styles.push(...resolvable.effects.map((text) => Colorette[text]));\n\t\t\tif (resolvable.text) styles.push(Colorette[resolvable.text]);\n\t\t\tif (resolvable.background) styles.push(Colorette[resolvable.background]);\n\n\t\t\tthis.style = styles.length\n\t\t\t\t? styles.length === 1\n\t\t\t\t\t? styles[0]\n\t\t\t\t\t: (string) => styles.reduce((out, style) => style(out), string) as string\n\t\t\t\t: Colorette.reset;\n\t\t}\n\t}\n\n\t/**\n\t * Applies the style to a string.\n\t * @since 1.0.0\n\t * @param string The value to apply the style to.\n\t */\n\tpublic run(string: string | number) {\n\t\treturn this.style(string);\n\t}\n}\n\n/**\n * The options for {@link LoggerStyle}.\n * @since 1.0.0\n */\nexport interface LoggerStyleOptions {\n\t/**\n\t * The text effects, e.g. `italic`, `strikethrough`, etc.\n\t * @since 1.0.0\n\t */\n\teffects?: LoggerStyleEffect[];\n\n\t/**\n\t * The text color, e.g. `red` or `yellow`.\n\t * @since 1.0.0\n\t */\n\ttext?: LoggerStyleText;\n\n\t/**\n\t * The background color, e.g. `magenta` or `red`.\n\t * @since 1.0.0\n\t */\n\tbackground?: LoggerStyleBackground;\n}\n\n/**\n * The value accepted by {@link LoggerStyle}'s constructor. Read `colorette`'s documentation for more information.\n * @since 1.0.0\n * @seealso https://www.npmjs.com/package/colorette\n */\nexport type LoggerStyleResolvable = Colorette.Color | LoggerStyleOptions;\n\n/**\n * The text styles.\n * @since 1.0.0\n */\nexport enum LoggerStyleEffect {\n\tReset = 'reset',\n\tBold = 'bold',\n\tDim = 'dim',\n\tItalic = 'italic',\n\tUnderline = 'underline',\n\tInverse = 'inverse',\n\tHidden = 'hidden',\n\tStrikethrough = 'strikethrough'\n}\n\n/**\n * The text colors.\n * @since 1.0.0\n */\nexport enum LoggerStyleText {\n\tBlack = 'black',\n\tRed = 'red',\n\tGreen = 'green',\n\tYellow = 'yellow',\n\tBlue = 'blue',\n\tMagenta = 'magenta',\n\tCyan = 'cyan',\n\tWhite = 'white',\n\tGray = 'gray',\n\tBlackBright = 'blackBright',\n\tRedBright = 'redBright',\n\tGreenBright = 'greenBright',\n\tYellowBright = 'yellowBright',\n\tBlueBright = 'blueBright',\n\tMagentaBright = 'magentaBright',\n\tCyanBright = 'cyanBright',\n\tWhiteBright = 'whiteBright'\n}\n\n/**\n * The background colors.\n * @since 1.0.0\n */\nexport enum LoggerStyleBackground {\n\tBlack = 'bgBlack',\n\tRed = 'bgRed',\n\tGreen = 'bgGreen',\n\tYellow = 'bgYellow',\n\tBlue = 'bgBlue',\n\tMagenta = 'bgMagenta',\n\tCyan = 'bgCyan',\n\tWhite = 'bgWhite',\n\tBlackBright = 'bgBlackBright',\n\tRedBright = 'bgRedBright',\n\tGreenBright = 'bgGreenBright',\n\tYellowBright = 'bgYellowBright',\n\tBlueBright = 'bgBlueBright',\n\tMagentaBright = 'bgMagentaBright',\n\tCyanBright = 'bgCyanBright',\n\tWhiteBright = 'bgWhiteBright'\n}\n"]}
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ var timestamp = require('@sapphire/timestamp');
4
+ var LoggerStyle_cjs = require('./LoggerStyle.cjs');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __publicField = (obj, key, value) => {
10
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
+ return value;
12
+ };
13
+ var _LoggerTimestamp = class _LoggerTimestamp {
14
+ constructor(options = {}) {
15
+ /**
16
+ * The timestamp used to format the current date.
17
+ * @since 1.0.0
18
+ */
19
+ __publicField(this, "timestamp");
20
+ /**
21
+ * Whether or not the logger will show a timestamp in UTC.
22
+ * @since 1.0.0
23
+ */
24
+ __publicField(this, "utc");
25
+ /**
26
+ * The logger style to apply the color to the timestamp.
27
+ * @since 1.0.0
28
+ */
29
+ __publicField(this, "color");
30
+ /**
31
+ * The final formatter.
32
+ * @since 1.0.0
33
+ */
34
+ __publicField(this, "formatter");
35
+ this.timestamp = new timestamp.Timestamp(options.pattern ?? "YYYY-MM-DD HH:mm:ss");
36
+ this.utc = options.utc ?? false;
37
+ this.color = options.color === null ? null : new LoggerStyle_cjs.LoggerStyle(options.color);
38
+ this.formatter = options.formatter ?? ((timestamp) => `${timestamp} - `);
39
+ }
40
+ /**
41
+ * Formats the current time.
42
+ * @since 1.0.0
43
+ */
44
+ run() {
45
+ const date = /* @__PURE__ */ new Date();
46
+ const result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date);
47
+ return this.formatter(this.color ? this.color.run(result) : result);
48
+ }
49
+ };
50
+ __name(_LoggerTimestamp, "LoggerTimestamp");
51
+ var LoggerTimestamp = _LoggerTimestamp;
52
+
53
+ exports.LoggerTimestamp = LoggerTimestamp;
54
+ //# sourceMappingURL=out.js.map
55
+ //# sourceMappingURL=LoggerTimestamp.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/lib/LoggerTimestamp.ts"],"names":[],"mappings":";;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,mBAA+C;AAMjD,IAAM,mBAAN,MAAM,iBAAgB;AAAA,EAyBrB,YAAY,UAAkC,CAAC,GAAG;AApBzD;AAAA;AAAA;AAAA;AAAA,wBAAO;AAMP;AAAA;AAAA;AAAA;AAAA,wBAAO;AAMP;AAAA;AAAA;AAAA;AAAA,wBAAO;AAMP;AAAA;AAAA;AAAA;AAAA,wBAAO;AAGN,SAAK,YAAY,IAAI,UAAU,QAAQ,WAAW,qBAAqB;AACvE,SAAK,MAAM,QAAQ,OAAO;AAC1B,SAAK,QAAQ,QAAQ,UAAU,OAAO,OAAO,IAAI,YAAY,QAAQ,KAAK;AAC1E,SAAK,YAAY,QAAQ,cAAc,CAAC,cAAc,GAAG,SAAS;AAAA,EACnE;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,MAAM;AACZ,UAAM,OAAO,oBAAI,KAAK;AACtB,UAAM,SAAS,KAAK,MAAM,KAAK,UAAU,WAAW,IAAI,IAAI,KAAK,UAAU,QAAQ,IAAI;AACvF,WAAO,KAAK,UAAU,KAAK,QAAQ,KAAK,MAAM,IAAI,MAAM,IAAI,MAAM;AAAA,EACnE;AACD;AAzC6B;AAAtB,IAAM,kBAAN","sourcesContent":["import { Timestamp } from '@sapphire/timestamp';\nimport { LoggerStyle, type LoggerStyleResolvable } from './LoggerStyle';\n\n/**\n * Logger utility that formats a timestamp.\n * @since 1.0.0\n */\nexport class LoggerTimestamp {\n\t/**\n\t * The timestamp used to format the current date.\n\t * @since 1.0.0\n\t */\n\tpublic timestamp: Timestamp;\n\n\t/**\n\t * Whether or not the logger will show a timestamp in UTC.\n\t * @since 1.0.0\n\t */\n\tpublic utc: boolean;\n\n\t/**\n\t * The logger style to apply the color to the timestamp.\n\t * @since 1.0.0\n\t */\n\tpublic color: LoggerStyle | null;\n\n\t/**\n\t * The final formatter.\n\t * @since 1.0.0\n\t */\n\tpublic formatter: LoggerTimestampFormatter;\n\n\tpublic constructor(options: LoggerTimestampOptions = {}) {\n\t\tthis.timestamp = new Timestamp(options.pattern ?? 'YYYY-MM-DD HH:mm:ss');\n\t\tthis.utc = options.utc ?? false;\n\t\tthis.color = options.color === null ? null : new LoggerStyle(options.color);\n\t\tthis.formatter = options.formatter ?? ((timestamp) => `${timestamp} - `);\n\t}\n\n\t/**\n\t * Formats the current time.\n\t * @since 1.0.0\n\t */\n\tpublic run() {\n\t\tconst date = new Date();\n\t\tconst result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date);\n\t\treturn this.formatter(this.color ? this.color.run(result) : result);\n\t}\n}\n\n/**\n * The options for {@link LoggerTimestamp}.\n * @since 1.0.0\n */\nexport interface LoggerTimestampOptions {\n\t/**\n\t * The {@link Timestamp} pattern.\n\t * @since 1.0.0\n\t * @default 'YYYY-MM-DD HH:mm:ss'\n\t * @example\n\t * ```typescript\n\t * 'YYYY-MM-DD HH:mm:ss'\n\t * // 2020-12-23 22:01:10\n\t * ```\n\t */\n\tpattern?: string;\n\n\t/**\n\t * Whether or not the date should be UTC.\n\t * @since 1.0.0\n\t * @default false\n\t */\n\tutc?: boolean;\n\n\t/**\n\t * The color to use.\n\t * @since 1.0.0\n\t * @default colorette.reset\n\t */\n\tcolor?: LoggerStyleResolvable | null;\n\n\t/**\n\t * The formatter. See {@link LoggerTimestampFormatter} for more information.\n\t * @since 1.0.0\n\t * @default (value) => `${value} - `\n\t */\n\tformatter?: LoggerTimestampFormatter;\n}\n\n/**\n * The formatter used for {@link LoggerTimestampOptions}. This will be run **after** applying the color to the formatter.\n * @since 1.0.0\n */\nexport interface LoggerTimestampFormatter {\n\t/**\n\t * @param timestamp The output of {@link LoggerStyle.run} on {@link Timestamp.display}/{@link Timestamp.displayUTC}.\n\t * @since 1.0.0\n\t */\n\t(timestamp: string): string;\n}\n"]}
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+
3
+ var framework = require('@sapphire/framework');
4
+ var Logger_cjs = require('./lib/Logger.cjs');
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
+ var _LoggerPlugin = class _LoggerPlugin extends framework.Plugin {
9
+ /**
10
+ * @since 1.0.0
11
+ */
12
+ static [framework.preGenericsInitialization](options) {
13
+ options.logger ??= {};
14
+ options.logger.instance = new Logger_cjs.Logger(options.logger);
15
+ }
16
+ };
17
+ __name(_LoggerPlugin, "LoggerPlugin");
18
+ var LoggerPlugin = _LoggerPlugin;
19
+ framework.SapphireClient.plugins.registerPreGenericsInitializationHook(LoggerPlugin[framework.preGenericsInitialization], "Logger-PreGenericsInitialization");
20
+
21
+ exports.LoggerPlugin = LoggerPlugin;
22
+ //# sourceMappingURL=out.js.map
23
+ //# sourceMappingURL=register.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/register.ts"],"names":[],"mappings":";;;;AAAA,SAAS,QAAQ,2BAA2B,sBAAsB;AAElE,SAAS,cAAkC;AAKpC,IAAM,gBAAN,MAAM,sBAAqB,OAAO;AAAA;AAAA;AAAA;AAAA,EAIxC,QAAe,yBAAyB,EAAwB,SAA8B;AAC7F,YAAQ,WAAW,CAAC;AACpB,YAAQ,OAAO,WAAW,IAAI,OAAO,QAAQ,MAAM;AAAA,EACpD;AACD;AARyC;AAAlC,IAAM,eAAN;AAcP,eAAe,QAAQ,sCAAsC,aAAa,yBAAyB,GAAG,kCAAkC","sourcesContent":["import { Plugin, preGenericsInitialization, SapphireClient } from '@sapphire/framework';\nimport type { ClientOptions } from 'discord.js';\nimport { Logger, type LoggerOptions } from './lib/Logger';\n\n/**\n * @since 1.0.0\n */\nexport class LoggerPlugin extends Plugin {\n\t/**\n\t * @since 1.0.0\n\t */\n\tpublic static [preGenericsInitialization](this: SapphireClient, options: ClientOptions): void {\n\t\toptions.logger ??= {};\n\t\toptions.logger.instance = new Logger(options.logger);\n\t}\n}\n\ndeclare module '@sapphire/framework' {\n\texport interface ClientLoggerOptions extends LoggerOptions {}\n}\n\nSapphireClient.plugins.registerPreGenericsInitializationHook(LoggerPlugin[preGenericsInitialization], 'Logger-PreGenericsInitialization');\n"]}
@@ -1,10 +1,11 @@
1
1
  import { Plugin, preGenericsInitialization, SapphireClient } from '@sapphire/framework';
2
- import type { ClientOptions } from 'discord.js';
3
- import { type LoggerOptions } from './lib/Logger';
2
+ import { ClientOptions } from 'discord.js';
3
+ import { LoggerOptions } from './lib/Logger.js';
4
+
4
5
  /**
5
6
  * @since 1.0.0
6
7
  */
7
- export declare class LoggerPlugin extends Plugin {
8
+ declare class LoggerPlugin extends Plugin {
8
9
  /**
9
10
  * @since 1.0.0
10
11
  */
@@ -14,4 +15,5 @@ declare module '@sapphire/framework' {
14
15
  interface ClientLoggerOptions extends LoggerOptions {
15
16
  }
16
17
  }
17
- //# sourceMappingURL=register.d.ts.map
18
+
19
+ export { LoggerPlugin };
@@ -0,0 +1,11 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
8
+
9
+ export { __name, __publicField };
10
+ //# sourceMappingURL=out.js.map
11
+ //# sourceMappingURL=chunk-6QB3UK4Q.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
@@ -0,0 +1,383 @@
1
+ import { Logger as Logger$1, LogLevel } from '@sapphire/framework';
2
+ import * as Colorette from 'colorette';
3
+ import { Timestamp } from '@sapphire/timestamp';
4
+
5
+ /**
6
+ * Logger utility that applies a style to a string.
7
+ * @since 1.0.0
8
+ */
9
+ declare class LoggerStyle {
10
+ readonly style: Colorette.Color;
11
+ constructor(resolvable?: LoggerStyleResolvable);
12
+ /**
13
+ * Applies the style to a string.
14
+ * @since 1.0.0
15
+ * @param string The value to apply the style to.
16
+ */
17
+ run(string: string | number): string;
18
+ }
19
+ /**
20
+ * The options for {@link LoggerStyle}.
21
+ * @since 1.0.0
22
+ */
23
+ interface LoggerStyleOptions {
24
+ /**
25
+ * The text effects, e.g. `italic`, `strikethrough`, etc.
26
+ * @since 1.0.0
27
+ */
28
+ effects?: LoggerStyleEffect[];
29
+ /**
30
+ * The text color, e.g. `red` or `yellow`.
31
+ * @since 1.0.0
32
+ */
33
+ text?: LoggerStyleText;
34
+ /**
35
+ * The background color, e.g. `magenta` or `red`.
36
+ * @since 1.0.0
37
+ */
38
+ background?: LoggerStyleBackground;
39
+ }
40
+ /**
41
+ * The value accepted by {@link LoggerStyle}'s constructor. Read `colorette`'s documentation for more information.
42
+ * @since 1.0.0
43
+ * @seealso https://www.npmjs.com/package/colorette
44
+ */
45
+ type LoggerStyleResolvable = Colorette.Color | LoggerStyleOptions;
46
+ /**
47
+ * The text styles.
48
+ * @since 1.0.0
49
+ */
50
+ declare enum LoggerStyleEffect {
51
+ Reset = "reset",
52
+ Bold = "bold",
53
+ Dim = "dim",
54
+ Italic = "italic",
55
+ Underline = "underline",
56
+ Inverse = "inverse",
57
+ Hidden = "hidden",
58
+ Strikethrough = "strikethrough"
59
+ }
60
+ /**
61
+ * The text colors.
62
+ * @since 1.0.0
63
+ */
64
+ declare enum LoggerStyleText {
65
+ Black = "black",
66
+ Red = "red",
67
+ Green = "green",
68
+ Yellow = "yellow",
69
+ Blue = "blue",
70
+ Magenta = "magenta",
71
+ Cyan = "cyan",
72
+ White = "white",
73
+ Gray = "gray",
74
+ BlackBright = "blackBright",
75
+ RedBright = "redBright",
76
+ GreenBright = "greenBright",
77
+ YellowBright = "yellowBright",
78
+ BlueBright = "blueBright",
79
+ MagentaBright = "magentaBright",
80
+ CyanBright = "cyanBright",
81
+ WhiteBright = "whiteBright"
82
+ }
83
+ /**
84
+ * The background colors.
85
+ * @since 1.0.0
86
+ */
87
+ declare enum LoggerStyleBackground {
88
+ Black = "bgBlack",
89
+ Red = "bgRed",
90
+ Green = "bgGreen",
91
+ Yellow = "bgYellow",
92
+ Blue = "bgBlue",
93
+ Magenta = "bgMagenta",
94
+ Cyan = "bgCyan",
95
+ White = "bgWhite",
96
+ BlackBright = "bgBlackBright",
97
+ RedBright = "bgRedBright",
98
+ GreenBright = "bgGreenBright",
99
+ YellowBright = "bgYellowBright",
100
+ BlueBright = "bgBlueBright",
101
+ MagentaBright = "bgMagentaBright",
102
+ CyanBright = "bgCyanBright",
103
+ WhiteBright = "bgWhiteBright"
104
+ }
105
+
106
+ /**
107
+ * Logger utility that formats a timestamp.
108
+ * @since 1.0.0
109
+ */
110
+ declare class LoggerTimestamp {
111
+ /**
112
+ * The timestamp used to format the current date.
113
+ * @since 1.0.0
114
+ */
115
+ timestamp: Timestamp;
116
+ /**
117
+ * Whether or not the logger will show a timestamp in UTC.
118
+ * @since 1.0.0
119
+ */
120
+ utc: boolean;
121
+ /**
122
+ * The logger style to apply the color to the timestamp.
123
+ * @since 1.0.0
124
+ */
125
+ color: LoggerStyle | null;
126
+ /**
127
+ * The final formatter.
128
+ * @since 1.0.0
129
+ */
130
+ formatter: LoggerTimestampFormatter;
131
+ constructor(options?: LoggerTimestampOptions);
132
+ /**
133
+ * Formats the current time.
134
+ * @since 1.0.0
135
+ */
136
+ run(): string;
137
+ }
138
+ /**
139
+ * The options for {@link LoggerTimestamp}.
140
+ * @since 1.0.0
141
+ */
142
+ interface LoggerTimestampOptions {
143
+ /**
144
+ * The {@link Timestamp} pattern.
145
+ * @since 1.0.0
146
+ * @default 'YYYY-MM-DD HH:mm:ss'
147
+ * @example
148
+ * ```typescript
149
+ * 'YYYY-MM-DD HH:mm:ss'
150
+ * // 2020-12-23 22:01:10
151
+ * ```
152
+ */
153
+ pattern?: string;
154
+ /**
155
+ * Whether or not the date should be UTC.
156
+ * @since 1.0.0
157
+ * @default false
158
+ */
159
+ utc?: boolean;
160
+ /**
161
+ * The color to use.
162
+ * @since 1.0.0
163
+ * @default colorette.reset
164
+ */
165
+ color?: LoggerStyleResolvable | null;
166
+ /**
167
+ * The formatter. See {@link LoggerTimestampFormatter} for more information.
168
+ * @since 1.0.0
169
+ * @default (value) => `${value} - `
170
+ */
171
+ formatter?: LoggerTimestampFormatter;
172
+ }
173
+ /**
174
+ * The formatter used for {@link LoggerTimestampOptions}. This will be run **after** applying the color to the formatter.
175
+ * @since 1.0.0
176
+ */
177
+ interface LoggerTimestampFormatter {
178
+ /**
179
+ * @param timestamp The output of {@link LoggerStyle.run} on {@link Timestamp.display}/{@link Timestamp.displayUTC}.
180
+ * @since 1.0.0
181
+ */
182
+ (timestamp: string): string;
183
+ }
184
+
185
+ /**
186
+ * Logger utility that stores and applies a full style into the message.
187
+ * @since 1.0.0
188
+ */
189
+ declare class LoggerLevel {
190
+ /**
191
+ * The timestamp formatter.
192
+ * @since 1.0.0
193
+ */
194
+ timestamp: LoggerTimestamp | null;
195
+ /**
196
+ * The infix, added between the timestamp and the message.
197
+ * @since 1.0.0
198
+ */
199
+ infix: string;
200
+ /**
201
+ * The style formatter for the message.
202
+ * @since 1.0.0
203
+ */
204
+ message: LoggerStyle | null;
205
+ constructor(options?: LoggerLevelOptions);
206
+ run(content: string): string;
207
+ }
208
+ /**
209
+ * The options for {@link LoggerLevel}.
210
+ * @since 1.0.0
211
+ */
212
+ interface LoggerLevelOptions {
213
+ /**
214
+ * The timestamp options. Set to `null` to disable timestamp parsing.
215
+ * @since 1.0.0
216
+ * @default {}
217
+ */
218
+ timestamp?: LoggerTimestampOptions | null;
219
+ /**
220
+ * The infix to be included between the timestamp and the message.
221
+ * @since 1.0.0
222
+ * @default ''
223
+ */
224
+ infix?: string;
225
+ /**
226
+ * The style options for the message.
227
+ * @since 1.0.0
228
+ * @default colorette.clear
229
+ */
230
+ message?: LoggerStyleResolvable | null;
231
+ }
232
+
233
+ /**
234
+ * The logger class.
235
+ * @since 1.0.0
236
+ */
237
+ declare class Logger extends Logger$1 {
238
+ /**
239
+ * The console this writes to.
240
+ * @since 1.0.0
241
+ */
242
+ readonly console: Console;
243
+ /**
244
+ * The formats supported by the logger.
245
+ * @since 1.0.0
246
+ */
247
+ readonly formats: Map<LogLevel, LoggerLevel>;
248
+ /**
249
+ * The string `write` will join values by.
250
+ * @since 1.0.0
251
+ */
252
+ readonly join: string;
253
+ /**
254
+ * The inspect depth when logging objects.
255
+ * @since 1.0.0
256
+ */
257
+ readonly depth: number;
258
+ constructor(options?: LoggerOptions);
259
+ /**
260
+ * Writes the log message given a level and the value(s).
261
+ * @param level The log level.
262
+ * @param values The values to log.
263
+ */
264
+ write(level: LogLevel, ...values: readonly unknown[]): void;
265
+ /**
266
+ * Pre-processes an array of values.
267
+ * @since 1.0.0
268
+ * @param values The values to pre-process.
269
+ */
270
+ protected preprocess(values: readonly unknown[]): string;
271
+ private get levels();
272
+ /**
273
+ * Gets whether or not colorette is enabled.
274
+ * @since 1.0.0
275
+ */
276
+ static get stylize(): boolean;
277
+ private static createFormatMap;
278
+ private static ensureDefaultLevel;
279
+ }
280
+ /**
281
+ * The logger options.
282
+ * @since 1.0.0
283
+ */
284
+ interface LoggerOptions {
285
+ /**
286
+ * A writable stream for the output logs.
287
+ * @since 1.0.0
288
+ * @default process.stdout
289
+ */
290
+ stdout?: NodeJS.WritableStream;
291
+ /**
292
+ * A writable stream for the error logs.
293
+ * @since 1.0.0
294
+ * @default process.stderr
295
+ */
296
+ stderr?: NodeJS.WritableStream;
297
+ /**
298
+ * The default options used to fill all the possible values for {@link LoggerOptions.format}.
299
+ * @since 1.0.0
300
+ * @default options.format.none ?? {}
301
+ */
302
+ defaultFormat?: LoggerLevelOptions;
303
+ /**
304
+ * The options for each log level. LogLevel.None serves to set the default for all keys, where only
305
+ * {@link LoggerTimestampOptions.timestamp} and {@link LoggerLevelOptions.prefix} would be overridden.
306
+ * @since 1.0.0
307
+ * @default {}
308
+ */
309
+ format?: LoggerFormatOptions;
310
+ /**
311
+ * The minimum log level.
312
+ * @since 1.0.0
313
+ * @default LogLevel.Info
314
+ */
315
+ level?: LogLevel;
316
+ /**
317
+ * The string that joins different messages.
318
+ * @since 1.0.0
319
+ * @default ' '
320
+ */
321
+ join?: string;
322
+ /**
323
+ * The inspect depth when logging objects.
324
+ * @since 1.0.0
325
+ * @default 0
326
+ */
327
+ depth?: number;
328
+ }
329
+ /**
330
+ * The logger format options.
331
+ * @since 1.0.0
332
+ */
333
+ interface LoggerFormatOptions {
334
+ /**
335
+ * The logger options for the lowest log level, used when calling {@link ILogger.trace}.
336
+ * @since 1.0.0
337
+ */
338
+ trace?: LoggerLevelOptions;
339
+ /**
340
+ * The logger options for the debug level, used when calling {@link ILogger.debug}.
341
+ * @since 1.0.0
342
+ */
343
+ debug?: LoggerLevelOptions;
344
+ /**
345
+ * The logger options for the info level, used when calling {@link ILogger.info}.
346
+ * @since 1.0.0
347
+ */
348
+ info?: LoggerLevelOptions;
349
+ /**
350
+ * The logger options for the warning level, used when calling {@link ILogger.warn}.
351
+ * @since 1.0.0
352
+ */
353
+ warn?: LoggerLevelOptions;
354
+ /**
355
+ * The logger options for the error level, used when calling {@link ILogger.error}.
356
+ * @since 1.0.0
357
+ */
358
+ error?: LoggerLevelOptions;
359
+ /**
360
+ * The logger options for the critical level, used when calling {@link ILogger.fatal}.
361
+ * @since 1.0.0
362
+ */
363
+ fatal?: LoggerLevelOptions;
364
+ /**
365
+ * The logger options for an unknown or uncategorised level.
366
+ * @since 1.0.0
367
+ */
368
+ none?: LoggerLevelOptions;
369
+ }
370
+
371
+ declare module '@sapphire/framework' {
372
+ interface ClientLoggerOptions extends LoggerOptions {
373
+ }
374
+ }
375
+ /**
376
+ * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.
377
+ * An example use of this is showing it of in a bot information command.
378
+ *
379
+ * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild
380
+ */
381
+ declare const version: string;
382
+
383
+ export { Logger, type LoggerFormatOptions, LoggerLevel, type LoggerLevelOptions, type LoggerOptions, LoggerStyle, LoggerStyleBackground, LoggerStyleEffect, type LoggerStyleOptions, type LoggerStyleResolvable, LoggerStyleText, LoggerTimestamp, type LoggerTimestampFormatter, type LoggerTimestampOptions, version };
@@ -0,0 +1,11 @@
1
+ import './chunk-6QB3UK4Q.mjs';
2
+ export * from './lib/Logger.mjs';
3
+ export * from './lib/LoggerLevel.mjs';
4
+ export * from './lib/LoggerStyle.mjs';
5
+ export * from './lib/LoggerTimestamp.mjs';
6
+
7
+ var version = "4.0.0-pr-512.86f3d06.0";
8
+
9
+ export { version };
10
+ //# sourceMappingURL=out.js.map
11
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;AAEA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAaP,IAAM,UAAkB","sourcesContent":["import type { LoggerOptions } from './lib/Logger';\n\nexport * from './lib/Logger';\nexport * from './lib/LoggerLevel';\nexport * from './lib/LoggerStyle';\nexport * from './lib/LoggerTimestamp';\n\ndeclare module '@sapphire/framework' {\n\texport interface ClientLoggerOptions extends LoggerOptions {}\n}\n\n/**\n * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '4.0.0-pr-512.86f3d06.0';\n"]}