@atlaspack/logger 2.14.5-canary.33 → 2.14.5-canary.331

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,228 @@
1
1
  # @atlaspack/logger
2
2
 
3
+ ## 2.14.36
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`362a85d`](https://github.com/atlassian-labs/atlaspack/commit/362a85deb9722f769eeb5099bae915f8b858a126), [`c81b368`](https://github.com/atlassian-labs/atlaspack/commit/c81b368db20af701d9e019a11272b138f9cfe080)]:
8
+ - @atlaspack/rust@3.15.0
9
+ - @atlaspack/types-internal@2.22.1
10
+
11
+ ## 2.14.35
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [[`00fa643`](https://github.com/atlassian-labs/atlaspack/commit/00fa6433202bfd3311479f6314c9ec878a789f2c)]:
16
+ - @atlaspack/types-internal@2.22.0
17
+
18
+ ## 2.14.34
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`787290a`](https://github.com/atlassian-labs/atlaspack/commit/787290a63b3f781e7af86097201dfdb5a36c8551), [`cbb66a5`](https://github.com/atlassian-labs/atlaspack/commit/cbb66a554f7ad679fd4dfc9e2bf2d5abb859f846), [`7815a93`](https://github.com/atlassian-labs/atlaspack/commit/7815a931b18983c3f34a39990b2f4b8b86855cc6), [`25aa273`](https://github.com/atlassian-labs/atlaspack/commit/25aa2735f4db920960de3d65d3a427775086b7d5), [`9468e16`](https://github.com/atlassian-labs/atlaspack/commit/9468e164e8ca20a5e8f552f5dc203aa3716cb154), [`e55c80c`](https://github.com/atlassian-labs/atlaspack/commit/e55c80cd0ae3cc40356fe063cb7d45fbb9095356)]:
23
+ - @atlaspack/rust@3.14.0
24
+ - @atlaspack/types-internal@2.21.3
25
+
26
+ ## 2.14.33
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [[`96f1d7f`](https://github.com/atlassian-labs/atlaspack/commit/96f1d7f3efef12ce4f5966e34d00b299fcefb4dd), [`91738fd`](https://github.com/atlassian-labs/atlaspack/commit/91738fd77cb6b3b7acc93e799327ec283d27f7c0), [`38f3569`](https://github.com/atlassian-labs/atlaspack/commit/38f3569a7024357c43274666312bc6d024bfe5f9), [`3f6a3b8`](https://github.com/atlassian-labs/atlaspack/commit/3f6a3b8df4589fd4d65c072281c7f33bd37341d6), [`96f1d7f`](https://github.com/atlassian-labs/atlaspack/commit/96f1d7f3efef12ce4f5966e34d00b299fcefb4dd), [`d8024ce`](https://github.com/atlassian-labs/atlaspack/commit/d8024ce5c9ced1a9bc39144c979138be3a12b2fb), [`308e7ff`](https://github.com/atlassian-labs/atlaspack/commit/308e7ff979c05c1ae97fe6b08a65666b53d86cc7), [`d98c992`](https://github.com/atlassian-labs/atlaspack/commit/d98c992a56121a4f9f6a011ced5e103f96fe3999)]:
31
+ - @atlaspack/rust@3.13.0
32
+ - @atlaspack/types-internal@2.21.2
33
+
34
+ ## 2.14.32
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [[`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b), [`25fee72`](https://github.com/atlassian-labs/atlaspack/commit/25fee723d2228d0482ec8a8f1b8379ccd2977ce7), [`6fac01d`](https://github.com/atlassian-labs/atlaspack/commit/6fac01dbb1bfc5b971176c1a1c008297bf4b8f91), [`432d571`](https://github.com/atlassian-labs/atlaspack/commit/432d571ea4e9fc67be12304fcafe8c445e844174), [`042cd95`](https://github.com/atlassian-labs/atlaspack/commit/042cd95a32ad38cd02d57aa3344c36d4e7ab8f9c), [`28f5424`](https://github.com/atlassian-labs/atlaspack/commit/28f5424f7e2080dd4fbbeb1bc5314a530197a23e), [`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b), [`5710532`](https://github.com/atlassian-labs/atlaspack/commit/57105322b26ce42af2cbfcc0506cff929e50b630), [`44eb8c3`](https://github.com/atlassian-labs/atlaspack/commit/44eb8c388d3e63f1ef5d835aee7aee5d1bb0620f)]:
39
+ - @atlaspack/rust@3.12.0
40
+ - @atlaspack/types-internal@2.21.1
41
+
42
+ ## 2.14.31
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [[`7dd5bd8`](https://github.com/atlassian-labs/atlaspack/commit/7dd5bd89ff60c7b324347d772729eb4c3314f01e), [`c8a0e51`](https://github.com/atlassian-labs/atlaspack/commit/c8a0e51b1096d038a64644ad02fe68383f58682a), [`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4), [`71900f3`](https://github.com/atlassian-labs/atlaspack/commit/71900f3508d53c3882ca8ea71501ba3069687d4e), [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13), [`2c4953e`](https://github.com/atlassian-labs/atlaspack/commit/2c4953e20dc1a6b012792081667aefeb9340505e), [`3fe7d4e`](https://github.com/atlassian-labs/atlaspack/commit/3fe7d4e821bee162fcbbaf9278b107a5eead944f)]:
47
+ - @atlaspack/rust@3.11.0
48
+ - @atlaspack/types-internal@2.21.0
49
+
50
+ ## 2.14.30
51
+
52
+ ### Patch Changes
53
+
54
+ - Updated dependencies [[`ec3abe4`](https://github.com/atlassian-labs/atlaspack/commit/ec3abe4dffc98560a850fd2f71fb566577e6c99c), [`c7fe3f7`](https://github.com/atlassian-labs/atlaspack/commit/c7fe3f76f247e9e20299e205e2df0a16c418eaf2), [`cfb4707`](https://github.com/atlassian-labs/atlaspack/commit/cfb4707087498e4fa4dcf10753fe984a248d196b), [`1468695`](https://github.com/atlassian-labs/atlaspack/commit/1468695fc0c9d06f060a6da9e9b0e154f11dff34), [`f31b041`](https://github.com/atlassian-labs/atlaspack/commit/f31b04107e9077c9946aadb99f6f91bb69703bb7), [`8180981`](https://github.com/atlassian-labs/atlaspack/commit/8180981be14c00f9570adb70d3f350bd91d6ec0a), [`ae77e74`](https://github.com/atlassian-labs/atlaspack/commit/ae77e7452a466b43b3fa5bed24d4ba26345ed765), [`f0a496f`](https://github.com/atlassian-labs/atlaspack/commit/f0a496f70fc8652e090cf1b3f6260e8cfbb796e2), [`540f253`](https://github.com/atlassian-labs/atlaspack/commit/540f253dfdcd1a5caebbdc0b197319d439404aae)]:
55
+ - @atlaspack/rust@3.10.0
56
+ - @atlaspack/types-internal@2.20.8
57
+
58
+ ## 2.14.29
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [[`339b600`](https://github.com/atlassian-labs/atlaspack/commit/339b60095d755742cea50f811d08ccc44a4ae521), [`373ee2d`](https://github.com/atlassian-labs/atlaspack/commit/373ee2d3b5cc315df1e90e647619f915892e2b87)]:
63
+ - @atlaspack/rust@3.9.1
64
+ - @atlaspack/types-internal@2.20.7
65
+
66
+ ## 2.14.28
67
+
68
+ ### Patch Changes
69
+
70
+ - Updated dependencies [[`02f6aa1`](https://github.com/atlassian-labs/atlaspack/commit/02f6aa1906953fc184d2b49c905c2ef815cb878d), [`58527ee`](https://github.com/atlassian-labs/atlaspack/commit/58527eec15c1aebaaadbeb63586f3082c16beae3), [`525898e`](https://github.com/atlassian-labs/atlaspack/commit/525898e33cc229a4bc938ae853732be36d20c01a), [`cfb39a0`](https://github.com/atlassian-labs/atlaspack/commit/cfb39a0d729eb620cf2ca1611750a2bf7a080d08), [`d0c7bea`](https://github.com/atlassian-labs/atlaspack/commit/d0c7bea04458255b4c5d4299600e734b5f919fe1), [`1086c6a`](https://github.com/atlassian-labs/atlaspack/commit/1086c6a2c59271b63b3fb78e6acdb9d3a0dbf354), [`9cd9521`](https://github.com/atlassian-labs/atlaspack/commit/9cd9521978f783046e2ae4ce78f2de7aeb07d073)]:
71
+ - @atlaspack/rust@3.9.0
72
+ - @atlaspack/types-internal@2.20.6
73
+
74
+ ## 2.14.27
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [[`79a7e22`](https://github.com/atlassian-labs/atlaspack/commit/79a7e22ef119891a2f4180a9d3cc66b38dd52092), [`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10), [`27fd73f`](https://github.com/atlassian-labs/atlaspack/commit/27fd73fa07d358653f1be6f2d15d72dc5d8fc2fd), [`3091fa3`](https://github.com/atlassian-labs/atlaspack/commit/3091fa36425ecffe3938e55247a035b08cda37a2)]:
79
+ - @atlaspack/rust@3.8.3
80
+ - @atlaspack/types-internal@2.20.5
81
+
82
+ ## 2.14.26
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies []:
87
+ - @atlaspack/types-internal@2.20.4
88
+
89
+ ## 2.14.25
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies []:
94
+ - @atlaspack/types-internal@2.20.3
95
+
96
+ ## 2.14.24
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [[`0207171`](https://github.com/atlassian-labs/atlaspack/commit/0207171e59e985c51e105aec2e0a99de174374bd), [`bbe4e28`](https://github.com/atlassian-labs/atlaspack/commit/bbe4e28c89e5e9284bd730075d4d6f2a3cb37b21)]:
101
+ - @atlaspack/rust@3.8.2
102
+ - @atlaspack/types-internal@2.20.2
103
+
104
+ ## 2.14.23
105
+
106
+ ### Patch Changes
107
+
108
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
109
+
110
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922), [`686a398`](https://github.com/atlassian-labs/atlaspack/commit/686a398faa1f9e19cbf9274add2c46e246bafba8)]:
111
+ - @atlaspack/diagnostic@2.14.4
112
+ - @atlaspack/rust@3.8.1
113
+ - @atlaspack/types-internal@2.20.1
114
+ - @atlaspack/events@2.14.4
115
+
116
+ ## 2.14.22
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`5a0363f`](https://github.com/atlassian-labs/atlaspack/commit/5a0363f1086e81068959b87e92064bed5a11a9b4), [`038e87a`](https://github.com/atlassian-labs/atlaspack/commit/038e87a7858d39556d59d3a2d17db534d45f62c6), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572), [`0684997`](https://github.com/atlassian-labs/atlaspack/commit/0684997c127a6204af1376b36e556fddd1ba5557), [`602f8ed`](https://github.com/atlassian-labs/atlaspack/commit/602f8ed9d8381301df8b2cc82c1d5cf6f2f94fec)]:
121
+ - @atlaspack/types-internal@2.20.0
122
+ - @atlaspack/rust@3.8.0
123
+
124
+ ## 2.14.21
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies [[`53dd47b`](https://github.com/atlassian-labs/atlaspack/commit/53dd47bd6d23cd47f87297347f03a609ab38a03d)]:
129
+ - @atlaspack/rust@3.7.0
130
+ - @atlaspack/types-internal@2.19.5
131
+
132
+ ## 2.14.20
133
+
134
+ ### Patch Changes
135
+
136
+ - Updated dependencies []:
137
+ - @atlaspack/types-internal@2.19.4
138
+
139
+ ## 2.14.19
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [[`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3)]:
144
+ - @atlaspack/rust@3.6.2
145
+ - @atlaspack/types-internal@2.19.3
146
+
147
+ ## 2.14.18
148
+
149
+ ### Patch Changes
150
+
151
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
152
+
153
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
154
+ - @atlaspack/types-internal@2.19.2
155
+ - @atlaspack/diagnostic@2.14.3
156
+ - @atlaspack/events@2.14.3
157
+ - @atlaspack/rust@3.6.1
158
+
159
+ ## 2.14.17
160
+
161
+ ### Patch Changes
162
+
163
+ - Updated dependencies []:
164
+ - @atlaspack/types-internal@2.19.1
165
+
166
+ ## 2.14.16
167
+
168
+ ### Patch Changes
169
+
170
+ - Updated dependencies [[`ad26146`](https://github.com/atlassian-labs/atlaspack/commit/ad26146f13b4c1cc65d4a0f9c67060b90ef14ff3), [`f1b48e7`](https://github.com/atlassian-labs/atlaspack/commit/f1b48e7a04e005cef0f36a3e692087a9ecdb6f7a), [`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
171
+ - @atlaspack/rust@3.6.0
172
+ - @atlaspack/types-internal@2.19.0
173
+
174
+ ## 2.14.15
175
+
176
+ ### Patch Changes
177
+
178
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
179
+ - @atlaspack/rust@3.5.0
180
+
181
+ ## 2.14.14
182
+
183
+ ### Patch Changes
184
+
185
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
186
+
187
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
188
+ - @atlaspack/diagnostic@2.14.2
189
+ - @atlaspack/events@2.14.2
190
+ - @atlaspack/rust@3.4.2
191
+
192
+ ## 2.14.13
193
+
194
+ ### Patch Changes
195
+
196
+ - Updated dependencies [[`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5)]:
197
+ - @atlaspack/rust@3.4.1
198
+
199
+ ## 2.14.12
200
+
201
+ ### Patch Changes
202
+
203
+ - Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
204
+ - @atlaspack/rust@3.4.0
205
+
206
+ ## 2.14.11
207
+
208
+ ### Patch Changes
209
+
210
+ - [#650](https://github.com/atlassian-labs/atlaspack/pull/650) [`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb) Thanks [@alshdavid](https://github.com/alshdavid)! - Remove package.json#exports
211
+
212
+ ## 2.14.10
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [[`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
217
+ - @atlaspack/rust@3.3.5
218
+
219
+ ## 2.14.9
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies [[`124b7ff`](https://github.com/atlassian-labs/atlaspack/commit/124b7fff44f71aac9fbad289a9a9509b3dfc9aaa), [`e052521`](https://github.com/atlassian-labs/atlaspack/commit/e0525210850ed1606146eb86991049cf567c5dec), [`15c6d70`](https://github.com/atlassian-labs/atlaspack/commit/15c6d7000bd89da876bc590aa75b17a619a41896), [`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6), [`42a775d`](https://github.com/atlassian-labs/atlaspack/commit/42a775de8eec638ad188f3271964170d8c04d84b), [`29c2f10`](https://github.com/atlassian-labs/atlaspack/commit/29c2f106de9679adfb5afa04e1910471dc65a427), [`1ef91fc`](https://github.com/atlassian-labs/atlaspack/commit/1ef91fcc863fdd2831511937083dbbc1263b3d9d)]:
224
+ - @atlaspack/rust@3.3.4
225
+
3
226
  ## 2.14.8
4
227
 
5
228
  ### Patch Changes
package/dist/Logger.js ADDED
@@ -0,0 +1,179 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.INTERNAL_ORIGINAL_CONSOLE = exports.PluginLogger = exports.instrumentAsync = exports.instrument = void 0;
4
+ exports.patchConsole = patchConsole;
5
+ exports.unpatchConsole = unpatchConsole;
6
+ const events_1 = require("@atlaspack/events");
7
+ const util_1 = require("util");
8
+ const diagnostic_1 = require("@atlaspack/diagnostic");
9
+ var tracer_1 = require("./tracer");
10
+ Object.defineProperty(exports, "instrument", { enumerable: true, get: function () { return tracer_1.instrument; } });
11
+ Object.defineProperty(exports, "instrumentAsync", { enumerable: true, get: function () { return tracer_1.instrumentAsync; } });
12
+ class Logger {
13
+ constructor() {
14
+ this.logEmitter = new events_1.ValueEmitter();
15
+ }
16
+ onLog(cb) {
17
+ return this.logEmitter.addListener(cb);
18
+ }
19
+ verbose(diagnostic) {
20
+ this.logEmitter.emit({
21
+ type: 'log',
22
+ level: 'verbose',
23
+ diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
24
+ });
25
+ }
26
+ info(diagnostic) {
27
+ this.log(diagnostic);
28
+ }
29
+ log(diagnostic) {
30
+ this.logEmitter.emit({
31
+ type: 'log',
32
+ level: 'info',
33
+ diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
34
+ });
35
+ }
36
+ warn(diagnostic) {
37
+ this.logEmitter.emit({
38
+ type: 'log',
39
+ level: 'warn',
40
+ diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
41
+ });
42
+ }
43
+ error(input, realOrigin) {
44
+ let diagnostic = (0, diagnostic_1.anyToDiagnostic)(input);
45
+ if (typeof realOrigin === 'string') {
46
+ diagnostic = Array.isArray(diagnostic)
47
+ ? diagnostic.map((d) => {
48
+ return { ...d, origin: realOrigin };
49
+ })
50
+ : {
51
+ ...diagnostic,
52
+ origin: realOrigin,
53
+ };
54
+ }
55
+ this.logEmitter.emit({
56
+ type: 'log',
57
+ level: 'error',
58
+ diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
59
+ });
60
+ }
61
+ progress(message) {
62
+ this.logEmitter.emit({
63
+ type: 'log',
64
+ level: 'progress',
65
+ message,
66
+ });
67
+ }
68
+ }
69
+ const logger = new Logger();
70
+ exports.default = logger;
71
+ class PluginLogger {
72
+ /** @private */
73
+ constructor(opts) {
74
+ this.origin = opts.origin;
75
+ }
76
+ /** @private */
77
+ updateOrigin(diagnostic) {
78
+ return Array.isArray(diagnostic)
79
+ ? diagnostic.map((d) => {
80
+ return { ...d, origin: this.origin };
81
+ })
82
+ : { ...diagnostic, origin: this.origin };
83
+ }
84
+ verbose(diagnostic) {
85
+ logger.verbose(this.updateOrigin(diagnostic));
86
+ }
87
+ info(diagnostic) {
88
+ logger.info(this.updateOrigin(diagnostic));
89
+ }
90
+ log(diagnostic) {
91
+ logger.log(this.updateOrigin(diagnostic));
92
+ }
93
+ warn(diagnostic) {
94
+ logger.warn(this.updateOrigin(diagnostic));
95
+ }
96
+ error(input) {
97
+ logger.error(input, this.origin);
98
+ }
99
+ /** @private */
100
+ progress(message) {
101
+ logger.progress(message);
102
+ }
103
+ }
104
+ exports.PluginLogger = PluginLogger;
105
+ /** @private */
106
+ exports.INTERNAL_ORIGINAL_CONSOLE = { ...console };
107
+ let consolePatched = false;
108
+ /**
109
+ * Patch `console` APIs within workers to forward their messages to the Logger
110
+ * at the appropriate levels.
111
+ * @private
112
+ */
113
+ function patchConsole() {
114
+ // Skip if console is already patched...
115
+ if (consolePatched)
116
+ return;
117
+ /* eslint-disable no-console */
118
+ console.log = console.info = (...messages) => {
119
+ logger.info(messagesToDiagnostic(messages));
120
+ };
121
+ console.debug = (...messages) => {
122
+ // TODO: dedicated debug level?
123
+ logger.verbose(messagesToDiagnostic(messages));
124
+ };
125
+ console.warn = (...messages) => {
126
+ logger.warn(messagesToDiagnostic(messages));
127
+ };
128
+ console.error = (...messages) => {
129
+ logger.error(messagesToDiagnostic(messages));
130
+ };
131
+ /* eslint-enable no-console */
132
+ consolePatched = true;
133
+ }
134
+ /** @private */
135
+ function unpatchConsole() {
136
+ // Skip if console isn't patched...
137
+ if (!consolePatched)
138
+ return;
139
+ /* eslint-disable no-console */
140
+ console.log = exports.INTERNAL_ORIGINAL_CONSOLE.log;
141
+ console.info = exports.INTERNAL_ORIGINAL_CONSOLE.info;
142
+ console.debug = exports.INTERNAL_ORIGINAL_CONSOLE.debug;
143
+ console.warn = exports.INTERNAL_ORIGINAL_CONSOLE.warn;
144
+ console.error = exports.INTERNAL_ORIGINAL_CONSOLE.error;
145
+ /* eslint-enable no-console */
146
+ consolePatched = false;
147
+ }
148
+ function messagesToDiagnostic(messages) {
149
+ if (messages.length === 1 && messages[0] instanceof Error) {
150
+ let error = messages[0];
151
+ let diagnostic = (0, diagnostic_1.errorToDiagnostic)(error);
152
+ if (Array.isArray(diagnostic)) {
153
+ return diagnostic.map((d) => {
154
+ return {
155
+ ...d,
156
+ skipFormatting: true,
157
+ };
158
+ });
159
+ }
160
+ else {
161
+ return {
162
+ ...diagnostic,
163
+ skipFormatting: true,
164
+ };
165
+ }
166
+ }
167
+ else {
168
+ return {
169
+ message: joinLogMessages(messages),
170
+ origin: 'console',
171
+ skipFormatting: true,
172
+ };
173
+ }
174
+ }
175
+ function joinLogMessages(messages) {
176
+ return messages
177
+ .map((m) => (typeof m === 'string' ? m : (0, util_1.inspect)(m)))
178
+ .join(' ');
179
+ }
package/dist/tracer.js ADDED
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tracer = void 0;
4
+ exports.instrument = instrument;
5
+ exports.instrumentAsync = instrumentAsync;
6
+ const rust_1 = require("@atlaspack/rust");
7
+ exports.tracer = new rust_1.AtlaspackTracer();
8
+ function instrument(label, fn) {
9
+ const span = exports.tracer.enter(label);
10
+ try {
11
+ const result = fn();
12
+ return result;
13
+ }
14
+ finally {
15
+ exports.tracer.exit(span);
16
+ }
17
+ }
18
+ async function instrumentAsync(label, fn) {
19
+ const span = exports.tracer.enter(label);
20
+ let result;
21
+ try {
22
+ result = await fn();
23
+ }
24
+ finally {
25
+ exports.tracer.exit(span);
26
+ }
27
+ return result;
28
+ }
package/lib/Logger.js CHANGED
@@ -41,12 +41,12 @@ function _diagnostic() {
41
41
  }
42
42
  var _tracer = require("./tracer");
43
43
  class Logger {
44
- #logEmitter /*: ValueEmitter<LogEvent> */ = new (_events().ValueEmitter)();
44
+ logEmitter = new (_events().ValueEmitter)();
45
45
  onLog(cb) {
46
- return this.#logEmitter.addListener(cb);
46
+ return this.logEmitter.addListener(cb);
47
47
  }
48
48
  verbose(diagnostic) {
49
- this.#logEmitter.emit({
49
+ this.logEmitter.emit({
50
50
  type: 'log',
51
51
  level: 'verbose',
52
52
  diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
@@ -56,14 +56,14 @@ class Logger {
56
56
  this.log(diagnostic);
57
57
  }
58
58
  log(diagnostic) {
59
- this.#logEmitter.emit({
59
+ this.logEmitter.emit({
60
60
  type: 'log',
61
61
  level: 'info',
62
62
  diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
63
63
  });
64
64
  }
65
65
  warn(diagnostic) {
66
- this.#logEmitter.emit({
66
+ this.logEmitter.emit({
67
67
  type: 'log',
68
68
  level: 'warn',
69
69
  diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
@@ -82,14 +82,14 @@ class Logger {
82
82
  origin: realOrigin
83
83
  };
84
84
  }
85
- this.#logEmitter.emit({
85
+ this.logEmitter.emit({
86
86
  type: 'log',
87
87
  level: 'error',
88
88
  diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
89
89
  });
90
90
  }
91
91
  progress(message) {
92
- this.#logEmitter.emit({
92
+ this.logEmitter.emit({
93
93
  type: 'log',
94
94
  level: 'progress',
95
95
  message
@@ -158,23 +158,16 @@ function patchConsole() {
158
158
  if (consolePatched) return;
159
159
 
160
160
  /* eslint-disable no-console */
161
- // $FlowFixMe
162
161
  console.log = console.info = (...messages) => {
163
162
  logger.info(messagesToDiagnostic(messages));
164
163
  };
165
-
166
- // $FlowFixMe
167
164
  console.debug = (...messages) => {
168
165
  // TODO: dedicated debug level?
169
166
  logger.verbose(messagesToDiagnostic(messages));
170
167
  };
171
-
172
- // $FlowFixMe
173
168
  console.warn = (...messages) => {
174
169
  logger.warn(messagesToDiagnostic(messages));
175
170
  };
176
-
177
- // $FlowFixMe
178
171
  console.error = (...messages) => {
179
172
  logger.error(messagesToDiagnostic(messages));
180
173
  };
@@ -189,19 +182,10 @@ function unpatchConsole() {
189
182
  if (!consolePatched) return;
190
183
 
191
184
  /* eslint-disable no-console */
192
- // $FlowFixMe
193
185
  console.log = INTERNAL_ORIGINAL_CONSOLE.log;
194
-
195
- // $FlowFixMe
196
186
  console.info = INTERNAL_ORIGINAL_CONSOLE.info;
197
-
198
- // $FlowFixMe
199
187
  console.debug = INTERNAL_ORIGINAL_CONSOLE.debug;
200
-
201
- // $FlowFixMe
202
188
  console.warn = INTERNAL_ORIGINAL_CONSOLE.warn;
203
-
204
- // $FlowFixMe
205
189
  console.error = INTERNAL_ORIGINAL_CONSOLE.error;
206
190
 
207
191
  /* eslint-enable no-console */
@@ -0,0 +1,129 @@
1
+ import type { IDisposable, LogEvent, PluginLogger as IPluginLogger } from '@atlaspack/types-internal';
2
+ import type { Diagnostic, Diagnostifiable, DiagnosticWithoutOrigin } from '@atlaspack/diagnostic';
3
+ import { ValueEmitter } from '@atlaspack/events';
4
+ export { instrument, instrumentAsync } from './tracer';
5
+ declare class Logger {
6
+ logEmitter: ValueEmitter<LogEvent>;
7
+ onLog(cb: (event: LogEvent) => unknown): IDisposable;
8
+ verbose(diagnostic: Diagnostic | Array<Diagnostic>): void;
9
+ info(diagnostic: Diagnostic | Array<Diagnostic>): void;
10
+ log(diagnostic: Diagnostic | Array<Diagnostic>): void;
11
+ warn(diagnostic: Diagnostic | Array<Diagnostic>): void;
12
+ error(input: Diagnostifiable, realOrigin?: string): void;
13
+ progress(message: string): void;
14
+ }
15
+ declare const logger: Logger;
16
+ export default logger;
17
+ /** @private */
18
+ export type PluginLoggerOpts = {
19
+ origin: string;
20
+ };
21
+ export declare class PluginLogger implements IPluginLogger {
22
+ /** @private */
23
+ origin: string;
24
+ /** @private */
25
+ constructor(opts: PluginLoggerOpts);
26
+ /** @private */
27
+ updateOrigin(diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>): Diagnostic | Array<Diagnostic>;
28
+ verbose(diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>): void;
29
+ info(diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>): void;
30
+ log(diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>): void;
31
+ warn(diagnostic: DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>): void;
32
+ error(input: Diagnostifiable | DiagnosticWithoutOrigin | Array<DiagnosticWithoutOrigin>): void;
33
+ /** @private */
34
+ progress(message: string): void;
35
+ }
36
+ /** @private */
37
+ export declare const INTERNAL_ORIGINAL_CONSOLE: {
38
+ readonly assert: {
39
+ (condition?: boolean, ...data: any[]): void;
40
+ (value: any, message?: string, ...optionalParams: any[]): void;
41
+ };
42
+ readonly clear: {
43
+ (): void;
44
+ (): void;
45
+ };
46
+ readonly count: {
47
+ (label?: string): void;
48
+ (label?: string): void;
49
+ };
50
+ readonly countReset: {
51
+ (label?: string): void;
52
+ (label?: string): void;
53
+ };
54
+ readonly debug: {
55
+ (...data: any[]): void;
56
+ (message?: any, ...optionalParams: any[]): void;
57
+ };
58
+ readonly dir: {
59
+ (item?: any, options?: any): void;
60
+ (obj: any, options?: import("util").InspectOptions): void;
61
+ };
62
+ readonly dirxml: {
63
+ (...data: any[]): void;
64
+ (...data: any[]): void;
65
+ };
66
+ readonly error: {
67
+ (...data: any[]): void;
68
+ (message?: any, ...optionalParams: any[]): void;
69
+ };
70
+ readonly group: {
71
+ (...data: any[]): void;
72
+ (...label: any[]): void;
73
+ };
74
+ readonly groupCollapsed: {
75
+ (...data: any[]): void;
76
+ (...label: any[]): void;
77
+ };
78
+ readonly groupEnd: {
79
+ (): void;
80
+ (): void;
81
+ };
82
+ readonly info: {
83
+ (...data: any[]): void;
84
+ (message?: any, ...optionalParams: any[]): void;
85
+ };
86
+ readonly log: {
87
+ (...data: any[]): void;
88
+ (message?: any, ...optionalParams: any[]): void;
89
+ };
90
+ readonly table: {
91
+ (tabularData?: any, properties?: string[]): void;
92
+ (tabularData: any, properties?: readonly string[]): void;
93
+ };
94
+ readonly time: {
95
+ (label?: string): void;
96
+ (label?: string): void;
97
+ };
98
+ readonly timeEnd: {
99
+ (label?: string): void;
100
+ (label?: string): void;
101
+ };
102
+ readonly timeLog: {
103
+ (label?: string, ...data: any[]): void;
104
+ (label?: string, ...data: any[]): void;
105
+ };
106
+ readonly timeStamp: {
107
+ (label?: string): void;
108
+ (label?: string): void;
109
+ };
110
+ readonly trace: {
111
+ (...data: any[]): void;
112
+ (message?: any, ...optionalParams: any[]): void;
113
+ };
114
+ readonly warn: {
115
+ (...data: any[]): void;
116
+ (message?: any, ...optionalParams: any[]): void;
117
+ };
118
+ readonly Console: console.ConsoleConstructor;
119
+ readonly profile: (label?: string) => void;
120
+ readonly profileEnd: (label?: string) => void;
121
+ };
122
+ /**
123
+ * Patch `console` APIs within workers to forward their messages to the Logger
124
+ * at the appropriate levels.
125
+ * @private
126
+ */
127
+ export declare function patchConsole(): void;
128
+ /** @private */
129
+ export declare function unpatchConsole(): void;
@@ -0,0 +1,4 @@
1
+ import { AtlaspackTracer } from '@atlaspack/rust';
2
+ export declare const tracer: AtlaspackTracer;
3
+ export declare function instrument<T>(label: string, fn: () => T): T;
4
+ export declare function instrumentAsync<T>(label: string, fn: () => Promise<T>): Promise<T>;