@atlaspack/logger 2.14.14-typescript-1fd1095e8.0 → 2.14.14-typescript-b27501580.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 (3) hide show
  1. package/package.json +10 -10
  2. package/lib/Logger.js +0 -221
  3. package/lib/tracer.js +0 -35
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/logger",
3
- "version": "2.14.14-typescript-1fd1095e8.0",
3
+ "version": "2.14.14-typescript-b27501580.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -10,20 +10,20 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/atlassian-labs/atlaspack.git"
12
12
  },
13
- "main": "lib/Logger.js",
14
- "source": "src/Logger.ts",
13
+ "main": "./lib/Logger.js",
14
+ "source": "./src/Logger.ts",
15
+ "types": "./lib/Logger.d.ts",
15
16
  "engines": {
16
17
  "node": ">= 16.0.0"
17
18
  },
18
19
  "dependencies": {
19
- "@atlaspack/diagnostic": "2.14.2-typescript-1fd1095e8.0",
20
- "@atlaspack/events": "2.14.2-typescript-1fd1095e8.0",
21
- "@atlaspack/rust": "3.4.2-typescript-1fd1095e8.0"
20
+ "@atlaspack/diagnostic": "2.14.2-typescript-b27501580.0",
21
+ "@atlaspack/events": "2.14.2-typescript-b27501580.0",
22
+ "@atlaspack/rust": "3.4.2-typescript-b27501580.0"
22
23
  },
23
24
  "type": "commonjs",
24
25
  "scripts": {
25
- "check-ts": "tsc --noEmit"
26
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src"
26
27
  },
27
- "types": "src/Logger.ts",
28
- "gitHead": "1fd1095e86da1e50d6c7819c0f132ce09a2bf396"
29
- }
28
+ "gitHead": "b275015805a058452afb6fb48c078ecd4de925f2"
29
+ }
package/lib/Logger.js DELETED
@@ -1,221 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = exports.PluginLogger = exports.INTERNAL_ORIGINAL_CONSOLE = void 0;
7
- Object.defineProperty(exports, "instrument", {
8
- enumerable: true,
9
- get: function () {
10
- return _tracer.instrument;
11
- }
12
- });
13
- Object.defineProperty(exports, "instrumentAsync", {
14
- enumerable: true,
15
- get: function () {
16
- return _tracer.instrumentAsync;
17
- }
18
- });
19
- exports.patchConsole = patchConsole;
20
- exports.unpatchConsole = unpatchConsole;
21
- function _events() {
22
- const data = require("@atlaspack/events");
23
- _events = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _util() {
29
- const data = require("util");
30
- _util = function () {
31
- return data;
32
- };
33
- return data;
34
- }
35
- function _diagnostic() {
36
- const data = require("@atlaspack/diagnostic");
37
- _diagnostic = function () {
38
- return data;
39
- };
40
- return data;
41
- }
42
- var _tracer = require("./tracer");
43
- class Logger {
44
- logEmitter = new (_events().ValueEmitter)();
45
- onLog(cb) {
46
- return this.logEmitter.addListener(cb);
47
- }
48
- verbose(diagnostic) {
49
- this.logEmitter.emit({
50
- type: 'log',
51
- level: 'verbose',
52
- diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
53
- });
54
- }
55
- info(diagnostic) {
56
- this.log(diagnostic);
57
- }
58
- log(diagnostic) {
59
- this.logEmitter.emit({
60
- type: 'log',
61
- level: 'info',
62
- diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
63
- });
64
- }
65
- warn(diagnostic) {
66
- this.logEmitter.emit({
67
- type: 'log',
68
- level: 'warn',
69
- diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
70
- });
71
- }
72
- error(input, realOrigin) {
73
- let diagnostic = (0, _diagnostic().anyToDiagnostic)(input);
74
- if (typeof realOrigin === 'string') {
75
- diagnostic = Array.isArray(diagnostic) ? diagnostic.map(d => {
76
- return {
77
- ...d,
78
- origin: realOrigin
79
- };
80
- }) : {
81
- ...diagnostic,
82
- origin: realOrigin
83
- };
84
- }
85
- this.logEmitter.emit({
86
- type: 'log',
87
- level: 'error',
88
- diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic]
89
- });
90
- }
91
- progress(message) {
92
- this.logEmitter.emit({
93
- type: 'log',
94
- level: 'progress',
95
- message
96
- });
97
- }
98
- }
99
- const logger = new Logger();
100
- var _default = exports.default = logger;
101
- /** @private */
102
- class PluginLogger {
103
- /** @private */
104
-
105
- /** @private */
106
- constructor(opts) {
107
- this.origin = opts.origin;
108
- }
109
-
110
- /** @private */
111
- updateOrigin(diagnostic) {
112
- return Array.isArray(diagnostic) ? diagnostic.map(d => {
113
- return {
114
- ...d,
115
- origin: this.origin
116
- };
117
- }) : {
118
- ...diagnostic,
119
- origin: this.origin
120
- };
121
- }
122
- verbose(diagnostic) {
123
- logger.verbose(this.updateOrigin(diagnostic));
124
- }
125
- info(diagnostic) {
126
- logger.info(this.updateOrigin(diagnostic));
127
- }
128
- log(diagnostic) {
129
- logger.log(this.updateOrigin(diagnostic));
130
- }
131
- warn(diagnostic) {
132
- logger.warn(this.updateOrigin(diagnostic));
133
- }
134
- error(input) {
135
- logger.error(input, this.origin);
136
- }
137
-
138
- /** @private */
139
- progress(message) {
140
- logger.progress(message);
141
- }
142
- }
143
-
144
- /** @private */
145
- exports.PluginLogger = PluginLogger;
146
- const INTERNAL_ORIGINAL_CONSOLE = exports.INTERNAL_ORIGINAL_CONSOLE = {
147
- ...console
148
- };
149
- let consolePatched = false;
150
-
151
- /**
152
- * Patch `console` APIs within workers to forward their messages to the Logger
153
- * at the appropriate levels.
154
- * @private
155
- */
156
- function patchConsole() {
157
- // Skip if console is already patched...
158
- if (consolePatched) return;
159
-
160
- /* eslint-disable no-console */
161
- console.log = console.info = (...messages) => {
162
- logger.info(messagesToDiagnostic(messages));
163
- };
164
- console.debug = (...messages) => {
165
- // TODO: dedicated debug level?
166
- logger.verbose(messagesToDiagnostic(messages));
167
- };
168
- console.warn = (...messages) => {
169
- logger.warn(messagesToDiagnostic(messages));
170
- };
171
- console.error = (...messages) => {
172
- logger.error(messagesToDiagnostic(messages));
173
- };
174
-
175
- /* eslint-enable no-console */
176
- consolePatched = true;
177
- }
178
-
179
- /** @private */
180
- function unpatchConsole() {
181
- // Skip if console isn't patched...
182
- if (!consolePatched) return;
183
-
184
- /* eslint-disable no-console */
185
- console.log = INTERNAL_ORIGINAL_CONSOLE.log;
186
- console.info = INTERNAL_ORIGINAL_CONSOLE.info;
187
- console.debug = INTERNAL_ORIGINAL_CONSOLE.debug;
188
- console.warn = INTERNAL_ORIGINAL_CONSOLE.warn;
189
- console.error = INTERNAL_ORIGINAL_CONSOLE.error;
190
-
191
- /* eslint-enable no-console */
192
- consolePatched = false;
193
- }
194
- function messagesToDiagnostic(messages) {
195
- if (messages.length === 1 && messages[0] instanceof Error) {
196
- let error = messages[0];
197
- let diagnostic = (0, _diagnostic().errorToDiagnostic)(error);
198
- if (Array.isArray(diagnostic)) {
199
- return diagnostic.map(d => {
200
- return {
201
- ...d,
202
- skipFormatting: true
203
- };
204
- });
205
- } else {
206
- return {
207
- ...diagnostic,
208
- skipFormatting: true
209
- };
210
- }
211
- } else {
212
- return {
213
- message: joinLogMessages(messages),
214
- origin: 'console',
215
- skipFormatting: true
216
- };
217
- }
218
- }
219
- function joinLogMessages(messages) {
220
- return messages.map(m => typeof m === 'string' ? m : (0, _util().inspect)(m)).join(' ');
221
- }
package/lib/tracer.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.instrument = instrument;
7
- exports.instrumentAsync = instrumentAsync;
8
- exports.tracer = void 0;
9
- function _rust() {
10
- const data = require("@atlaspack/rust");
11
- _rust = function () {
12
- return data;
13
- };
14
- return data;
15
- }
16
- const tracer = exports.tracer = new (_rust().AtlaspackTracer)();
17
- function instrument(label, fn) {
18
- const span = tracer.enter(label);
19
- try {
20
- const result = fn();
21
- return result;
22
- } finally {
23
- tracer.exit(span);
24
- }
25
- }
26
- async function instrumentAsync(label, fn) {
27
- const span = tracer.enter(label);
28
- let result;
29
- try {
30
- result = await fn();
31
- } finally {
32
- tracer.exit(span);
33
- }
34
- return result;
35
- }