@sapphire/plugin-logger 2.0.2 → 2.0.3-next.13bb97b.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.
@@ -1,58 +1,58 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoggerLevel = void 0;
4
- const LoggerStyle_1 = require('./LoggerStyle');
5
- const LoggerTimestamp_1 = require('./LoggerTimestamp');
4
+ const LoggerStyle_1 = require("./LoggerStyle");
5
+ const LoggerTimestamp_1 = require("./LoggerTimestamp");
6
6
  /**
7
7
  * Logger utility that stores and applies a full style into the message.
8
8
  * @since 1.0.0
9
9
  */
10
10
  class LoggerLevel {
11
- constructor(options = {}) {
12
- /**
13
- * The timestamp formatter.
14
- * @since 1.0.0
15
- */
16
- Object.defineProperty(this, 'timestamp', {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- /**
23
- * The infix, added between the timestamp and the message.
24
- * @since 1.0.0
25
- */
26
- Object.defineProperty(this, 'infix', {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- /**
33
- * The style formatter for the message.
34
- * @since 1.0.0
35
- */
36
- Object.defineProperty(this, 'message', {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- this.timestamp = options.timestamp === null ? null : new LoggerTimestamp_1.LoggerTimestamp(options.timestamp);
43
- this.infix = options.infix ?? '';
44
- this.message = options.message === null ? null : new LoggerStyle_1.LoggerStyle(options.message);
45
- }
46
- run(content) {
47
- const prefix = (this.timestamp?.run() ?? '') + this.infix;
48
- if (prefix.length) {
49
- const formatter = this.message //
50
- ? (line) => prefix + this.message.run(line)
51
- : (line) => prefix + line;
52
- return content.split('\n').map(formatter).join('\n');
53
- }
54
- return this.message ? this.message.run(content) : content;
55
- }
11
+ constructor(options = {}) {
12
+ /**
13
+ * The timestamp formatter.
14
+ * @since 1.0.0
15
+ */
16
+ Object.defineProperty(this, "timestamp", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ /**
23
+ * The infix, added between the timestamp and the message.
24
+ * @since 1.0.0
25
+ */
26
+ Object.defineProperty(this, "infix", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ /**
33
+ * The style formatter for the message.
34
+ * @since 1.0.0
35
+ */
36
+ Object.defineProperty(this, "message", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ this.timestamp = options.timestamp === null ? null : new LoggerTimestamp_1.LoggerTimestamp(options.timestamp);
43
+ this.infix = options.infix ?? '';
44
+ this.message = options.message === null ? null : new LoggerStyle_1.LoggerStyle(options.message);
45
+ }
46
+ run(content) {
47
+ const prefix = (this.timestamp?.run() ?? '') + this.infix;
48
+ if (prefix.length) {
49
+ const formatter = this.message //
50
+ ? (line) => prefix + this.message.run(line)
51
+ : (line) => prefix + line;
52
+ return content.split('\n').map(formatter).join('\n');
53
+ }
54
+ return this.message ? this.message.run(content) : content;
55
+ }
56
56
  }
57
57
  exports.LoggerLevel = LoggerLevel;
58
- //# sourceMappingURL=LoggerLevel.js.map
58
+ //# sourceMappingURL=LoggerLevel.js.map
@@ -1,42 +1,46 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoggerStyleBackground = exports.LoggerStyleText = exports.LoggerStyleEffect = exports.LoggerStyle = void 0;
4
- const tslib_1 = require('tslib');
5
- const Colorette = (0, tslib_1.__importStar)(require('colorette'));
4
+ const tslib_1 = require("tslib");
5
+ const Colorette = (0, tslib_1.__importStar)(require("colorette"));
6
6
  /**
7
7
  * Logger utility that applies a style to a string.
8
8
  * @since 1.0.0
9
9
  */
10
10
  class LoggerStyle {
11
- constructor(resolvable = {}) {
12
- Object.defineProperty(this, 'style', {
13
- enumerable: true,
14
- configurable: true,
15
- writable: true,
16
- value: void 0
17
- });
18
- if (typeof resolvable === 'function') {
19
- this.style = resolvable;
20
- } else {
21
- const styles = [];
22
- if (resolvable.effects) styles.push(...resolvable.effects.map((text) => Colorette[text]));
23
- if (resolvable.text) styles.push(Colorette[resolvable.text]);
24
- if (resolvable.background) styles.push(Colorette[resolvable.background]);
25
- this.style = styles.length
26
- ? styles.length === 1
27
- ? styles[0]
28
- : (string) => styles.reduce((out, style) => style(out), string)
29
- : Colorette.reset;
30
- }
31
- }
32
- /**
33
- * Applies the style to a string.
34
- * @since 1.0.0
35
- * @param string The value to apply the style to.
36
- */
37
- run(string) {
38
- return this.style(string);
39
- }
11
+ constructor(resolvable = {}) {
12
+ Object.defineProperty(this, "style", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ if (typeof resolvable === 'function') {
19
+ this.style = resolvable;
20
+ }
21
+ else {
22
+ const styles = [];
23
+ if (resolvable.effects)
24
+ styles.push(...resolvable.effects.map((text) => Colorette[text]));
25
+ if (resolvable.text)
26
+ styles.push(Colorette[resolvable.text]);
27
+ if (resolvable.background)
28
+ styles.push(Colorette[resolvable.background]);
29
+ this.style = styles.length
30
+ ? styles.length === 1
31
+ ? styles[0]
32
+ : (string) => styles.reduce((out, style) => style(out), string)
33
+ : Colorette.reset;
34
+ }
35
+ }
36
+ /**
37
+ * Applies the style to a string.
38
+ * @since 1.0.0
39
+ * @param string The value to apply the style to.
40
+ */
41
+ run(string) {
42
+ return this.style(string);
43
+ }
40
44
  }
41
45
  exports.LoggerStyle = LoggerStyle;
42
46
  /**
@@ -45,60 +49,60 @@ exports.LoggerStyle = LoggerStyle;
45
49
  */
46
50
  var LoggerStyleEffect;
47
51
  (function (LoggerStyleEffect) {
48
- LoggerStyleEffect['Reset'] = 'reset';
49
- LoggerStyleEffect['Bold'] = 'bold';
50
- LoggerStyleEffect['Dim'] = 'dim';
51
- LoggerStyleEffect['Italic'] = 'italic';
52
- LoggerStyleEffect['Underline'] = 'underline';
53
- LoggerStyleEffect['Inverse'] = 'inverse';
54
- LoggerStyleEffect['Hidden'] = 'hidden';
55
- LoggerStyleEffect['Strikethrough'] = 'strikethrough';
56
- })((LoggerStyleEffect = exports.LoggerStyleEffect || (exports.LoggerStyleEffect = {})));
52
+ LoggerStyleEffect["Reset"] = "reset";
53
+ LoggerStyleEffect["Bold"] = "bold";
54
+ LoggerStyleEffect["Dim"] = "dim";
55
+ LoggerStyleEffect["Italic"] = "italic";
56
+ LoggerStyleEffect["Underline"] = "underline";
57
+ LoggerStyleEffect["Inverse"] = "inverse";
58
+ LoggerStyleEffect["Hidden"] = "hidden";
59
+ LoggerStyleEffect["Strikethrough"] = "strikethrough";
60
+ })(LoggerStyleEffect = exports.LoggerStyleEffect || (exports.LoggerStyleEffect = {}));
57
61
  /**
58
62
  * The text colors.
59
63
  * @since 1.0.0
60
64
  */
61
65
  var LoggerStyleText;
62
66
  (function (LoggerStyleText) {
63
- LoggerStyleText['Black'] = 'black';
64
- LoggerStyleText['Red'] = 'red';
65
- LoggerStyleText['Green'] = 'green';
66
- LoggerStyleText['Yellow'] = 'yellow';
67
- LoggerStyleText['Blue'] = 'blue';
68
- LoggerStyleText['Magenta'] = 'magenta';
69
- LoggerStyleText['Cyan'] = 'cyan';
70
- LoggerStyleText['White'] = 'white';
71
- LoggerStyleText['Gray'] = 'gray';
72
- LoggerStyleText['BlackBright'] = 'blackBright';
73
- LoggerStyleText['RedBright'] = 'redBright';
74
- LoggerStyleText['GreenBright'] = 'greenBright';
75
- LoggerStyleText['YellowBright'] = 'yellowBright';
76
- LoggerStyleText['BlueBright'] = 'blueBright';
77
- LoggerStyleText['MagentaBright'] = 'magentaBright';
78
- LoggerStyleText['CyanBright'] = 'cyanBright';
79
- LoggerStyleText['WhiteBright'] = 'whiteBright';
80
- })((LoggerStyleText = exports.LoggerStyleText || (exports.LoggerStyleText = {})));
67
+ LoggerStyleText["Black"] = "black";
68
+ LoggerStyleText["Red"] = "red";
69
+ LoggerStyleText["Green"] = "green";
70
+ LoggerStyleText["Yellow"] = "yellow";
71
+ LoggerStyleText["Blue"] = "blue";
72
+ LoggerStyleText["Magenta"] = "magenta";
73
+ LoggerStyleText["Cyan"] = "cyan";
74
+ LoggerStyleText["White"] = "white";
75
+ LoggerStyleText["Gray"] = "gray";
76
+ LoggerStyleText["BlackBright"] = "blackBright";
77
+ LoggerStyleText["RedBright"] = "redBright";
78
+ LoggerStyleText["GreenBright"] = "greenBright";
79
+ LoggerStyleText["YellowBright"] = "yellowBright";
80
+ LoggerStyleText["BlueBright"] = "blueBright";
81
+ LoggerStyleText["MagentaBright"] = "magentaBright";
82
+ LoggerStyleText["CyanBright"] = "cyanBright";
83
+ LoggerStyleText["WhiteBright"] = "whiteBright";
84
+ })(LoggerStyleText = exports.LoggerStyleText || (exports.LoggerStyleText = {}));
81
85
  /**
82
86
  * The background colors.
83
87
  * @since 1.0.0
84
88
  */
85
89
  var LoggerStyleBackground;
86
90
  (function (LoggerStyleBackground) {
87
- LoggerStyleBackground['Black'] = 'bgBlack';
88
- LoggerStyleBackground['Red'] = 'bgRed';
89
- LoggerStyleBackground['Green'] = 'bgGreen';
90
- LoggerStyleBackground['Yellow'] = 'bgYellow';
91
- LoggerStyleBackground['Blue'] = 'bgBlue';
92
- LoggerStyleBackground['Magenta'] = 'bgMagenta';
93
- LoggerStyleBackground['Cyan'] = 'bgCyan';
94
- LoggerStyleBackground['White'] = 'bgWhite';
95
- LoggerStyleBackground['BlackBright'] = 'bgBlackBright';
96
- LoggerStyleBackground['RedBright'] = 'bgRedBright';
97
- LoggerStyleBackground['GreenBright'] = 'bgGreenBright';
98
- LoggerStyleBackground['YellowBright'] = 'bgYellowBright';
99
- LoggerStyleBackground['BlueBright'] = 'bgBlueBright';
100
- LoggerStyleBackground['MagentaBright'] = 'bgMagentaBright';
101
- LoggerStyleBackground['CyanBright'] = 'bgCyanBright';
102
- LoggerStyleBackground['WhiteBright'] = 'bgWhiteBright';
103
- })((LoggerStyleBackground = exports.LoggerStyleBackground || (exports.LoggerStyleBackground = {})));
104
- //# sourceMappingURL=LoggerStyle.js.map
91
+ LoggerStyleBackground["Black"] = "bgBlack";
92
+ LoggerStyleBackground["Red"] = "bgRed";
93
+ LoggerStyleBackground["Green"] = "bgGreen";
94
+ LoggerStyleBackground["Yellow"] = "bgYellow";
95
+ LoggerStyleBackground["Blue"] = "bgBlue";
96
+ LoggerStyleBackground["Magenta"] = "bgMagenta";
97
+ LoggerStyleBackground["Cyan"] = "bgCyan";
98
+ LoggerStyleBackground["White"] = "bgWhite";
99
+ LoggerStyleBackground["BlackBright"] = "bgBlackBright";
100
+ LoggerStyleBackground["RedBright"] = "bgRedBright";
101
+ LoggerStyleBackground["GreenBright"] = "bgGreenBright";
102
+ LoggerStyleBackground["YellowBright"] = "bgYellowBright";
103
+ LoggerStyleBackground["BlueBright"] = "bgBlueBright";
104
+ LoggerStyleBackground["MagentaBright"] = "bgMagentaBright";
105
+ LoggerStyleBackground["CyanBright"] = "bgCyanBright";
106
+ LoggerStyleBackground["WhiteBright"] = "bgWhiteBright";
107
+ })(LoggerStyleBackground = exports.LoggerStyleBackground || (exports.LoggerStyleBackground = {}));
108
+ //# sourceMappingURL=LoggerStyle.js.map
@@ -1,68 +1,68 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoggerTimestamp = void 0;
4
- const time_utilities_1 = require('@sapphire/time-utilities');
5
- const LoggerStyle_1 = require('./LoggerStyle');
4
+ const time_utilities_1 = require("@sapphire/time-utilities");
5
+ const LoggerStyle_1 = require("./LoggerStyle");
6
6
  /**
7
7
  * Logger utility that formats a timestamp.
8
8
  * @since 1.0.0
9
9
  */
10
10
  class LoggerTimestamp {
11
- constructor(options = {}) {
12
- /**
13
- * The timestamp used to format the current date.
14
- * @since 1.0.0
15
- */
16
- Object.defineProperty(this, 'timestamp', {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- /**
23
- * Whether or not the logger will show a timestamp in UTC.
24
- * @since 1.0.0
25
- */
26
- Object.defineProperty(this, 'utc', {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- /**
33
- * The logger style to apply the color to the timestamp.
34
- * @since 1.0.0
35
- */
36
- Object.defineProperty(this, 'color', {
37
- enumerable: true,
38
- configurable: true,
39
- writable: true,
40
- value: void 0
41
- });
42
- /**
43
- * The final formatter.
44
- * @since 1.0.0
45
- */
46
- Object.defineProperty(this, 'formatter', {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: void 0
51
- });
52
- this.timestamp = new time_utilities_1.Timestamp(options.pattern ?? 'YYYY-MM-DD HH:mm:ss');
53
- this.utc = options.utc ?? false;
54
- this.color = options.color === null ? null : new LoggerStyle_1.LoggerStyle(options.color);
55
- this.formatter = options.formatter ?? ((timestamp) => `${timestamp} - `);
56
- }
57
- /**
58
- * Formats the current time.
59
- * @since 1.0.0
60
- */
61
- run() {
62
- const date = new Date();
63
- const result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date);
64
- return this.formatter(this.color ? this.color.run(result) : result);
65
- }
11
+ constructor(options = {}) {
12
+ /**
13
+ * The timestamp used to format the current date.
14
+ * @since 1.0.0
15
+ */
16
+ Object.defineProperty(this, "timestamp", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: void 0
21
+ });
22
+ /**
23
+ * Whether or not the logger will show a timestamp in UTC.
24
+ * @since 1.0.0
25
+ */
26
+ Object.defineProperty(this, "utc", {
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true,
30
+ value: void 0
31
+ });
32
+ /**
33
+ * The logger style to apply the color to the timestamp.
34
+ * @since 1.0.0
35
+ */
36
+ Object.defineProperty(this, "color", {
37
+ enumerable: true,
38
+ configurable: true,
39
+ writable: true,
40
+ value: void 0
41
+ });
42
+ /**
43
+ * The final formatter.
44
+ * @since 1.0.0
45
+ */
46
+ Object.defineProperty(this, "formatter", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ this.timestamp = new time_utilities_1.Timestamp(options.pattern ?? 'YYYY-MM-DD HH:mm:ss');
53
+ this.utc = options.utc ?? false;
54
+ this.color = options.color === null ? null : new LoggerStyle_1.LoggerStyle(options.color);
55
+ this.formatter = options.formatter ?? ((timestamp) => `${timestamp} - `);
56
+ }
57
+ /**
58
+ * Formats the current time.
59
+ * @since 1.0.0
60
+ */
61
+ run() {
62
+ const date = new Date();
63
+ const result = this.utc ? this.timestamp.displayUTC(date) : this.timestamp.display(date);
64
+ return this.formatter(this.color ? this.color.run(result) : result);
65
+ }
66
66
  }
67
67
  exports.LoggerTimestamp = LoggerTimestamp;
68
- //# sourceMappingURL=LoggerTimestamp.js.map
68
+ //# sourceMappingURL=LoggerTimestamp.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/plugin-logger",
3
- "version": "2.0.2",
3
+ "version": "2.0.3-next.13bb97b.0",
4
4
  "description": "Plugin for @sapphire/framework to have pretty console output",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "prepublishOnly": "yarn build"
34
34
  },
35
35
  "dependencies": {
36
- "@sapphire/time-utilities": "^1.4.7",
36
+ "@sapphire/time-utilities": "^1.4.9",
37
37
  "colorette": "^2.0.16",
38
38
  "tslib": "^2.3.1"
39
39
  },
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "13ea3258845d66442eb4e1949f2c7f58420df33f"
70
+ "gitHead": "13bb97bb3fcffab310a8873672dea71a152c5a4a"
71
71
  }