@lwrjs/diagnostics 0.11.4 → 0.11.6
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/build/cjs/logger.cjs +31 -6
- package/build/es/logger.d.ts +9 -4
- package/build/es/logger.js +36 -8
- package/package.json +3 -3
package/build/cjs/logger.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(exports, {
|
|
|
34
34
|
stringifyError: () => stringifyError
|
|
35
35
|
});
|
|
36
36
|
var import_errors = __toModule(require("./errors.cjs"));
|
|
37
|
+
var import_util = __toModule(require("util"));
|
|
37
38
|
var SILENT = "silent";
|
|
38
39
|
var VERBOSE = "verbose";
|
|
39
40
|
var DEBUG = "debug";
|
|
@@ -76,7 +77,7 @@ function log(level, message, additionalInfo) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
const logMessage = `[${level}]${gap(message)}${message}`;
|
|
79
|
-
const additionalMessage = additionalInfo ? `Additional Info: ${
|
|
80
|
+
const additionalMessage = additionalInfo ? `Additional Info: ${(0, import_util.inspect)(additionalInfo)}` : void 0;
|
|
80
81
|
if (level == ERROR) {
|
|
81
82
|
console.error("[31m%s[0m", logMessage);
|
|
82
83
|
if (additionalInfo) {
|
|
@@ -117,7 +118,7 @@ var stringifyError = (error) => {
|
|
|
117
118
|
const descriptor = Object.getOwnPropertyDescriptor(error, property);
|
|
118
119
|
retObj[property] = descriptor?.value;
|
|
119
120
|
}
|
|
120
|
-
return
|
|
121
|
+
return (0, import_util.inspect)(retObj);
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
function gap(message) {
|
|
@@ -133,10 +134,34 @@ function logError(err, additionalInfo) {
|
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
136
|
var logger = {
|
|
136
|
-
verbose: (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
verbose: (info, additionalInfo) => {
|
|
138
|
+
if (typeof info === "string") {
|
|
139
|
+
log(VERBOSE, info, additionalInfo);
|
|
140
|
+
} else {
|
|
141
|
+
log(VERBOSE, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
debug: (info, additionalInfo) => {
|
|
145
|
+
if (typeof info === "string") {
|
|
146
|
+
log(DEBUG, info, additionalInfo);
|
|
147
|
+
} else {
|
|
148
|
+
log(DEBUG, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
info: (info, additionalInfo) => {
|
|
152
|
+
if (typeof info === "string") {
|
|
153
|
+
log(INFO, info, additionalInfo);
|
|
154
|
+
} else {
|
|
155
|
+
log(INFO, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
warn: (info, additionalInfo) => {
|
|
159
|
+
if (typeof info === "string") {
|
|
160
|
+
log(WARN, info, additionalInfo);
|
|
161
|
+
} else {
|
|
162
|
+
log(WARN, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
140
165
|
error: (error, additionalInfo) => logError(error, additionalInfo),
|
|
141
166
|
log,
|
|
142
167
|
setOptions: (opts) => {
|
package/build/es/logger.d.ts
CHANGED
|
@@ -11,11 +11,16 @@ type LoggerOptions = {
|
|
|
11
11
|
declare function getLogLevel(): string;
|
|
12
12
|
declare function log(level: LEVEL, message: string, additionalInfo?: any): void;
|
|
13
13
|
export declare const stringifyError: (error: any) => string;
|
|
14
|
+
export type LogMetadata = {
|
|
15
|
+
message: string;
|
|
16
|
+
label: string;
|
|
17
|
+
additionalInfo?: any;
|
|
18
|
+
};
|
|
14
19
|
export declare const logger: {
|
|
15
|
-
verbose: (
|
|
16
|
-
debug: (
|
|
17
|
-
info: (
|
|
18
|
-
warn: (
|
|
20
|
+
verbose: (info: string | LogMetadata, additionalInfo?: any) => void;
|
|
21
|
+
debug: (info: string | LogMetadata, additionalInfo?: any) => void;
|
|
22
|
+
info: (info: string | LogMetadata, additionalInfo?: any) => void;
|
|
23
|
+
warn: (info: string | LogMetadata, additionalInfo?: any) => void;
|
|
19
24
|
error: (error: any, additionalInfo?: any) => void;
|
|
20
25
|
log: typeof log;
|
|
21
26
|
setOptions: (opts: LoggerOptions) => void;
|
package/build/es/logger.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DiagnosticsError } from './errors.js';
|
|
2
|
+
import { inspect } from 'util';
|
|
2
3
|
export const SILENT = 'silent';
|
|
3
4
|
export const VERBOSE = 'verbose';
|
|
4
5
|
export const DEBUG = 'debug';
|
|
@@ -44,9 +45,7 @@ function log(level, message, additionalInfo) {
|
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
47
|
const logMessage = `[${level}]${gap(message)}${message}`;
|
|
47
|
-
const additionalMessage = additionalInfo
|
|
48
|
-
? `Additional Info: ${JSON.stringify(additionalInfo)}`
|
|
49
|
-
: undefined;
|
|
48
|
+
const additionalMessage = additionalInfo ? `Additional Info: ${inspect(additionalInfo)}` : undefined;
|
|
50
49
|
if (level == ERROR) {
|
|
51
50
|
console.error('\x1b[31m%s\x1b[0m', logMessage); // red
|
|
52
51
|
if (additionalInfo) {
|
|
@@ -91,7 +90,7 @@ export const stringifyError = (error) => {
|
|
|
91
90
|
const descriptor = Object.getOwnPropertyDescriptor(error, property);
|
|
92
91
|
retObj[property] = descriptor?.value;
|
|
93
92
|
}
|
|
94
|
-
return
|
|
93
|
+
return inspect(retObj);
|
|
95
94
|
}
|
|
96
95
|
};
|
|
97
96
|
// Return a space if there should be a space between the message and the level
|
|
@@ -109,10 +108,39 @@ function logError(err, additionalInfo) {
|
|
|
109
108
|
}
|
|
110
109
|
}
|
|
111
110
|
export const logger = {
|
|
112
|
-
verbose: (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
verbose: (info, additionalInfo) => {
|
|
112
|
+
if (typeof info === 'string') {
|
|
113
|
+
log(VERBOSE, info, additionalInfo);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
log(VERBOSE, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
debug: (info, additionalInfo) => {
|
|
120
|
+
if (typeof info === 'string') {
|
|
121
|
+
log(DEBUG, info, additionalInfo);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
log(DEBUG, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
info: (info, additionalInfo) => {
|
|
128
|
+
if (typeof info === 'string') {
|
|
129
|
+
log(INFO, info, additionalInfo);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
log(INFO, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
warn: (info, additionalInfo) => {
|
|
136
|
+
if (typeof info === 'string') {
|
|
137
|
+
log(WARN, info, additionalInfo);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
log(WARN, `[${info.label}] ${info.message}`, info.additionalInfo || additionalInfo);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
// TODO should logger.error accept a label or is that overkill
|
|
116
144
|
error: (error, additionalInfo) => logError(error, additionalInfo),
|
|
117
145
|
log,
|
|
118
146
|
setOptions: (opts) => {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.
|
|
7
|
+
"version": "0.11.6",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"test": "jest"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@lwrjs/types": "0.11.
|
|
38
|
+
"@lwrjs/types": "0.11.6",
|
|
39
39
|
"jest": "^26.6.3",
|
|
40
40
|
"ts-jest": "^26.5.6",
|
|
41
41
|
"typescript": "^4.9.5"
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=16.0.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "415e25c05b4b1a0356fb89801f1242e8f73143e3"
|
|
47
47
|
}
|