@atlaspack/logger 2.14.5-canary.16 → 2.14.5-canary.161
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 +83 -0
- package/lib/Logger.js +7 -23
- package/lib/types/Logger.d.ts +69 -0
- package/lib/types/tracer.d.ts +4 -0
- package/package.json +13 -13
- package/src/{Logger.js → Logger.ts} +22 -33
- package/src/{tracer.js → tracer.ts} +0 -2
- package/test/{Logger.test.js → Logger.test.ts} +2 -4
- package/tsconfig.json +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,88 @@
|
|
|
1
1
|
# @atlaspack/logger
|
|
2
2
|
|
|
3
|
+
## 2.14.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies []:
|
|
8
|
+
- @atlaspack/types-internal@2.19.1
|
|
9
|
+
|
|
10
|
+
## 2.14.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 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)]:
|
|
15
|
+
- @atlaspack/rust@3.6.0
|
|
16
|
+
- @atlaspack/types-internal@2.19.0
|
|
17
|
+
|
|
18
|
+
## 2.14.15
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
23
|
+
- @atlaspack/rust@3.5.0
|
|
24
|
+
|
|
25
|
+
## 2.14.14
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- [#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
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
|
|
32
|
+
- @atlaspack/diagnostic@2.14.2
|
|
33
|
+
- @atlaspack/events@2.14.2
|
|
34
|
+
- @atlaspack/rust@3.4.2
|
|
35
|
+
|
|
36
|
+
## 2.14.13
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- Updated dependencies [[`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5)]:
|
|
41
|
+
- @atlaspack/rust@3.4.1
|
|
42
|
+
|
|
43
|
+
## 2.14.12
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
|
|
48
|
+
- @atlaspack/rust@3.4.0
|
|
49
|
+
|
|
50
|
+
## 2.14.11
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- [#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
|
|
55
|
+
|
|
56
|
+
## 2.14.10
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Updated dependencies [[`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
|
|
61
|
+
- @atlaspack/rust@3.3.5
|
|
62
|
+
|
|
63
|
+
## 2.14.9
|
|
64
|
+
|
|
65
|
+
### Patch Changes
|
|
66
|
+
|
|
67
|
+
- 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)]:
|
|
68
|
+
- @atlaspack/rust@3.3.4
|
|
69
|
+
|
|
70
|
+
## 2.14.8
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Updated dependencies [[`1ab0a27`](https://github.com/atlassian-labs/atlaspack/commit/1ab0a275aeca40350415e2b03e7440d1dddc6228), [`b8a4ae8`](https://github.com/atlassian-labs/atlaspack/commit/b8a4ae8f83dc0a83d8b145c5f729936ce52080a3)]:
|
|
75
|
+
- @atlaspack/rust@3.3.3
|
|
76
|
+
|
|
77
|
+
## 2.14.7
|
|
78
|
+
|
|
79
|
+
### Patch Changes
|
|
80
|
+
|
|
81
|
+
- [#549](https://github.com/atlassian-labs/atlaspack/pull/549) [`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix log file RUST_LOG levels
|
|
82
|
+
|
|
83
|
+
- Updated dependencies [[`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
|
|
84
|
+
- @atlaspack/rust@3.3.2
|
|
85
|
+
|
|
3
86
|
## 2.14.6
|
|
4
87
|
|
|
5
88
|
### Patch Changes
|
package/lib/Logger.js
CHANGED
|
@@ -41,12 +41,12 @@ function _diagnostic() {
|
|
|
41
41
|
}
|
|
42
42
|
var _tracer = require("./tracer");
|
|
43
43
|
class Logger {
|
|
44
|
-
|
|
44
|
+
logEmitter = new (_events().ValueEmitter)();
|
|
45
45
|
onLog(cb) {
|
|
46
|
-
return this
|
|
46
|
+
return this.logEmitter.addListener(cb);
|
|
47
47
|
}
|
|
48
48
|
verbose(diagnostic) {
|
|
49
|
-
this
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,69 @@
|
|
|
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 Console: console.ConsoleConstructor;
|
|
39
|
+
readonly assert: (value: any, message?: string, ...optionalParams: any[]) => void;
|
|
40
|
+
readonly clear: () => void;
|
|
41
|
+
readonly count: (label?: string) => void;
|
|
42
|
+
readonly countReset: (label?: string) => void;
|
|
43
|
+
readonly debug: (message?: any, ...optionalParams: any[]) => void;
|
|
44
|
+
readonly dir: (obj: any, options?: import("util").InspectOptions) => void;
|
|
45
|
+
readonly dirxml: (...data: any[]) => void;
|
|
46
|
+
readonly error: (message?: any, ...optionalParams: any[]) => void;
|
|
47
|
+
readonly group: (...label: any[]) => void;
|
|
48
|
+
readonly groupCollapsed: (...label: any[]) => void;
|
|
49
|
+
readonly groupEnd: () => void;
|
|
50
|
+
readonly info: (message?: any, ...optionalParams: any[]) => void;
|
|
51
|
+
readonly log: (message?: any, ...optionalParams: any[]) => void;
|
|
52
|
+
readonly table: (tabularData: any, properties?: readonly string[]) => void;
|
|
53
|
+
readonly time: (label?: string) => void;
|
|
54
|
+
readonly timeEnd: (label?: string) => void;
|
|
55
|
+
readonly timeLog: (label?: string, ...data: any[]) => void;
|
|
56
|
+
readonly trace: (message?: any, ...optionalParams: any[]) => void;
|
|
57
|
+
readonly warn: (message?: any, ...optionalParams: any[]) => void;
|
|
58
|
+
readonly profile: (label?: string) => void;
|
|
59
|
+
readonly profileEnd: (label?: string) => void;
|
|
60
|
+
readonly timeStamp: (label?: string) => void;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Patch `console` APIs within workers to forward their messages to the Logger
|
|
64
|
+
* at the appropriate levels.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
export declare function patchConsole(): void;
|
|
68
|
+
/** @private */
|
|
69
|
+
export declare function unpatchConsole(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/logger",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.161+ee040bb64",
|
|
4
4
|
"description": "Blazing fast, zero configuration web application bundler",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,22 +10,22 @@
|
|
|
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.
|
|
15
|
-
"
|
|
16
|
-
".": {
|
|
17
|
-
"@atlaspack::sources": "./src/Logger.js",
|
|
18
|
-
"default": "./lib/Logger.js"
|
|
19
|
-
}
|
|
20
|
-
},
|
|
13
|
+
"main": "./lib/Logger.js",
|
|
14
|
+
"source": "./src/Logger.ts",
|
|
15
|
+
"types": "./lib/types/Logger.d.ts",
|
|
21
16
|
"engines": {
|
|
22
17
|
"node": ">= 16.0.0"
|
|
23
18
|
},
|
|
24
19
|
"dependencies": {
|
|
25
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
26
|
-
"@atlaspack/events": "2.14.1-canary.
|
|
27
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
20
|
+
"@atlaspack/diagnostic": "2.14.1-canary.229+ee040bb64",
|
|
21
|
+
"@atlaspack/events": "2.14.1-canary.229+ee040bb64",
|
|
22
|
+
"@atlaspack/rust": "3.2.1-canary.161+ee040bb64",
|
|
23
|
+
"@atlaspack/types-internal": "2.14.1-canary.229+ee040bb64"
|
|
28
24
|
},
|
|
29
25
|
"type": "commonjs",
|
|
30
|
-
"
|
|
26
|
+
"scripts": {
|
|
27
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
28
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
29
|
+
},
|
|
30
|
+
"gitHead": "ee040bb6428f29b57d892ddd8107e29077d08ffd"
|
|
31
31
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import type {
|
|
4
2
|
IDisposable,
|
|
5
3
|
LogEvent,
|
|
6
4
|
PluginLogger as IPluginLogger,
|
|
7
|
-
} from '@atlaspack/types';
|
|
5
|
+
} from '@atlaspack/types-internal';
|
|
8
6
|
import type {
|
|
9
7
|
Diagnostic,
|
|
10
8
|
Diagnostifiable,
|
|
@@ -18,14 +16,14 @@ import {errorToDiagnostic, anyToDiagnostic} from '@atlaspack/diagnostic';
|
|
|
18
16
|
export {instrument, instrumentAsync} from './tracer';
|
|
19
17
|
|
|
20
18
|
class Logger {
|
|
21
|
-
|
|
19
|
+
logEmitter: ValueEmitter<LogEvent> = new ValueEmitter();
|
|
22
20
|
|
|
23
|
-
onLog(cb: (event: LogEvent) =>
|
|
24
|
-
return this
|
|
21
|
+
onLog(cb: (event: LogEvent) => unknown): IDisposable {
|
|
22
|
+
return this.logEmitter.addListener(cb);
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
verbose(diagnostic: Diagnostic | Array<Diagnostic>): void {
|
|
28
|
-
this
|
|
26
|
+
this.logEmitter.emit({
|
|
29
27
|
type: 'log',
|
|
30
28
|
level: 'verbose',
|
|
31
29
|
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
|
|
@@ -37,7 +35,7 @@ class Logger {
|
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
log(diagnostic: Diagnostic | Array<Diagnostic>): void {
|
|
40
|
-
this
|
|
38
|
+
this.logEmitter.emit({
|
|
41
39
|
type: 'log',
|
|
42
40
|
level: 'info',
|
|
43
41
|
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
|
|
@@ -45,7 +43,7 @@ class Logger {
|
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
warn(diagnostic: Diagnostic | Array<Diagnostic>): void {
|
|
48
|
-
this
|
|
46
|
+
this.logEmitter.emit({
|
|
49
47
|
type: 'log',
|
|
50
48
|
level: 'warn',
|
|
51
49
|
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
|
|
@@ -53,7 +51,7 @@ class Logger {
|
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
error(input: Diagnostifiable, realOrigin?: string): void {
|
|
56
|
-
let diagnostic = anyToDiagnostic(input)
|
|
54
|
+
let diagnostic = anyToDiagnostic(input) as Diagnostic | Array<Diagnostic>;
|
|
57
55
|
if (typeof realOrigin === 'string') {
|
|
58
56
|
diagnostic = Array.isArray(diagnostic)
|
|
59
57
|
? diagnostic.map((d) => {
|
|
@@ -65,7 +63,7 @@ class Logger {
|
|
|
65
63
|
};
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
this
|
|
66
|
+
this.logEmitter.emit({
|
|
69
67
|
type: 'log',
|
|
70
68
|
level: 'error',
|
|
71
69
|
diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
|
|
@@ -73,7 +71,7 @@ class Logger {
|
|
|
73
71
|
}
|
|
74
72
|
|
|
75
73
|
progress(message: string): void {
|
|
76
|
-
this
|
|
74
|
+
this.logEmitter.emit({
|
|
77
75
|
type: 'log',
|
|
78
76
|
level: 'progress',
|
|
79
77
|
message,
|
|
@@ -85,9 +83,9 @@ const logger: Logger = new Logger();
|
|
|
85
83
|
export default logger;
|
|
86
84
|
|
|
87
85
|
/** @private */
|
|
88
|
-
export type PluginLoggerOpts = {
|
|
89
|
-
origin: string
|
|
90
|
-
|
|
86
|
+
export type PluginLoggerOpts = {
|
|
87
|
+
origin: string;
|
|
88
|
+
};
|
|
91
89
|
|
|
92
90
|
export class PluginLogger implements IPluginLogger {
|
|
93
91
|
/** @private */
|
|
@@ -106,7 +104,7 @@ export class PluginLogger implements IPluginLogger {
|
|
|
106
104
|
? diagnostic.map((d) => {
|
|
107
105
|
return {...d, origin: this.origin};
|
|
108
106
|
})
|
|
109
|
-
: {...diagnostic, origin: this.origin};
|
|
107
|
+
: ({...diagnostic, origin: this.origin} as Diagnostic);
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
verbose(
|
|
@@ -149,7 +147,7 @@ export class PluginLogger implements IPluginLogger {
|
|
|
149
147
|
}
|
|
150
148
|
|
|
151
149
|
/** @private */
|
|
152
|
-
export const INTERNAL_ORIGINAL_CONSOLE = {...console};
|
|
150
|
+
export const INTERNAL_ORIGINAL_CONSOLE = {...console} as const;
|
|
153
151
|
let consolePatched = false;
|
|
154
152
|
|
|
155
153
|
/**
|
|
@@ -162,24 +160,20 @@ export function patchConsole() {
|
|
|
162
160
|
if (consolePatched) return;
|
|
163
161
|
|
|
164
162
|
/* eslint-disable no-console */
|
|
165
|
-
|
|
166
|
-
console.log = console.info = (...messages: Array<mixed>) => {
|
|
163
|
+
console.log = console.info = (...messages: Array<unknown>) => {
|
|
167
164
|
logger.info(messagesToDiagnostic(messages));
|
|
168
165
|
};
|
|
169
166
|
|
|
170
|
-
|
|
171
|
-
console.debug = (...messages: Array<mixed>) => {
|
|
167
|
+
console.debug = (...messages: Array<unknown>) => {
|
|
172
168
|
// TODO: dedicated debug level?
|
|
173
169
|
logger.verbose(messagesToDiagnostic(messages));
|
|
174
170
|
};
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
console.warn = (...messages: Array<mixed>) => {
|
|
172
|
+
console.warn = (...messages: Array<unknown>) => {
|
|
178
173
|
logger.warn(messagesToDiagnostic(messages));
|
|
179
174
|
};
|
|
180
175
|
|
|
181
|
-
|
|
182
|
-
console.error = (...messages: Array<mixed>) => {
|
|
176
|
+
console.error = (...messages: Array<unknown>) => {
|
|
183
177
|
logger.error(messagesToDiagnostic(messages));
|
|
184
178
|
};
|
|
185
179
|
|
|
@@ -193,19 +187,14 @@ export function unpatchConsole() {
|
|
|
193
187
|
if (!consolePatched) return;
|
|
194
188
|
|
|
195
189
|
/* eslint-disable no-console */
|
|
196
|
-
// $FlowFixMe
|
|
197
190
|
console.log = INTERNAL_ORIGINAL_CONSOLE.log;
|
|
198
191
|
|
|
199
|
-
// $FlowFixMe
|
|
200
192
|
console.info = INTERNAL_ORIGINAL_CONSOLE.info;
|
|
201
193
|
|
|
202
|
-
// $FlowFixMe
|
|
203
194
|
console.debug = INTERNAL_ORIGINAL_CONSOLE.debug;
|
|
204
195
|
|
|
205
|
-
// $FlowFixMe
|
|
206
196
|
console.warn = INTERNAL_ORIGINAL_CONSOLE.warn;
|
|
207
197
|
|
|
208
|
-
// $FlowFixMe
|
|
209
198
|
console.error = INTERNAL_ORIGINAL_CONSOLE.error;
|
|
210
199
|
|
|
211
200
|
/* eslint-enable no-console */
|
|
@@ -213,11 +202,11 @@ export function unpatchConsole() {
|
|
|
213
202
|
}
|
|
214
203
|
|
|
215
204
|
function messagesToDiagnostic(
|
|
216
|
-
messages: Array<
|
|
205
|
+
messages: Array<unknown>,
|
|
217
206
|
): Diagnostic | Array<Diagnostic> {
|
|
218
207
|
if (messages.length === 1 && messages[0] instanceof Error) {
|
|
219
208
|
let error: Error = messages[0];
|
|
220
|
-
let diagnostic = errorToDiagnostic(error)
|
|
209
|
+
let diagnostic = errorToDiagnostic(error) as Diagnostic | Array<Diagnostic>;
|
|
221
210
|
|
|
222
211
|
if (Array.isArray(diagnostic)) {
|
|
223
212
|
return diagnostic.map((d) => {
|
|
@@ -241,7 +230,7 @@ function messagesToDiagnostic(
|
|
|
241
230
|
}
|
|
242
231
|
}
|
|
243
232
|
|
|
244
|
-
function joinLogMessages(messages: Array<
|
|
233
|
+
function joinLogMessages(messages: Array<unknown>): string {
|
|
245
234
|
return messages
|
|
246
235
|
.map((m) => (typeof m === 'string' ? m : inspect(m)))
|
|
247
236
|
.join(' ');
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
// @flow strict-local
|
|
2
|
-
|
|
3
1
|
import assert from 'assert';
|
|
4
2
|
import sinon from 'sinon';
|
|
5
3
|
import Logger from '../src/Logger';
|
|
6
4
|
|
|
7
5
|
describe('Logger', () => {
|
|
8
|
-
let onLog;
|
|
9
|
-
let logDisposable;
|
|
6
|
+
let onLog: any;
|
|
7
|
+
let logDisposable: any;
|
|
10
8
|
beforeEach(() => {
|
|
11
9
|
onLog = sinon.spy();
|
|
12
10
|
logDisposable = Logger.onLog(onLog);
|
package/tsconfig.json
ADDED