nightingale-formatter 14.2.0 → 15.0.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.
- package/CHANGELOG.md +23 -0
- package/dist/index-browser.es.js +193 -198
- package/dist/index-browser.es.js.map +1 -1
- package/dist/index-node18.mjs +0 -2
- package/dist/index-node18.mjs.map +1 -1
- package/package.json +7 -14
- package/dist/index-browsermodern.es.js +0 -523
- package/dist/index-browsermodern.es.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [15.0.0](https://github.com/christophehurpeau/nightingale/compare/v14.2.1...v15.0.0) (2023-12-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### ⚠ BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* update babel and drop browser modern version
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* update babel and drop browser modern version ([5c76abc](https://github.com/christophehurpeau/nightingale/commit/5c76abc8bfb595a617fc4c8b795dae7e674ea664))
|
|
16
|
+
|
|
17
|
+
Version bump for dependency: nightingale-levels
|
|
18
|
+
Version bump for dependency: nightingale-types
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [14.2.1](https://github.com/christophehurpeau/nightingale/compare/v14.2.0...v14.2.1) (2023-11-05)
|
|
22
|
+
|
|
23
|
+
Note: no notable changes
|
|
24
|
+
|
|
25
|
+
Version bump for dependency: nightingale-levels
|
|
26
|
+
Version bump for dependency: nightingale-types
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [14.2.0](https://github.com/christophehurpeau/nightingale/compare/v14.1.0...v14.2.0) (2023-11-04)
|
|
7
30
|
|
|
8
31
|
|
package/dist/index-browser.es.js
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import { Level } from 'nightingale-levels';
|
|
2
|
-
import _extends from '@babel/runtime/helpers/esm/extends';
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const levelToStyles = {
|
|
4
|
+
[Level.TRACE]: ['gray'],
|
|
5
|
+
[Level.DEBUG]: ['gray'],
|
|
6
|
+
// [Level.INFO]: ['gray'],
|
|
7
|
+
[Level.WARN]: ['yellow'],
|
|
8
|
+
[Level.ERROR]: ['red', 'bold'],
|
|
9
|
+
[Level.CRITICAL]: ['red', 'bold'],
|
|
10
|
+
[Level.FATAL]: ['bgRed', 'white'],
|
|
11
|
+
[Level.EMERGENCY]: ['bgRed', 'white']
|
|
12
|
+
};
|
|
6
13
|
|
|
7
|
-
|
|
8
|
-
|
|
14
|
+
const levelToSymbol = {
|
|
15
|
+
[Level.TRACE]: '•',
|
|
16
|
+
[Level.DEBUG]: '•',
|
|
17
|
+
[Level.INFO]: '→',
|
|
18
|
+
[Level.WARN]: '⚠',
|
|
19
|
+
[Level.ERROR]: '✖',
|
|
20
|
+
[Level.CRITICAL]: '!',
|
|
21
|
+
[Level.FATAL]: '‼',
|
|
22
|
+
[Level.EMERGENCY]: '‼'
|
|
23
|
+
};
|
|
9
24
|
|
|
10
|
-
|
|
25
|
+
const styleToHexColor = {
|
|
11
26
|
orange: 'ff5f00',
|
|
12
27
|
grayLight: '808080',
|
|
13
28
|
'gray-light': '808080'
|
|
14
29
|
};
|
|
15
30
|
|
|
16
|
-
|
|
31
|
+
const styleToHtmlStyleThemeLight = {
|
|
17
32
|
// text style
|
|
18
33
|
bold: {
|
|
19
34
|
open: 'font-weight: bold',
|
|
@@ -104,19 +119,20 @@ var styleToHtmlStyleThemeLight = {
|
|
|
104
119
|
close: 'background: initial'
|
|
105
120
|
},
|
|
106
121
|
orange: {
|
|
107
|
-
open:
|
|
122
|
+
open: `color: #${styleToHexColor.orange}`,
|
|
108
123
|
close: 'color: currentcolor'
|
|
109
124
|
},
|
|
110
125
|
grayLight: {
|
|
111
|
-
open:
|
|
126
|
+
open: `color: #${styleToHexColor.grayLight}`,
|
|
112
127
|
close: 'color: currentcolor'
|
|
113
128
|
},
|
|
114
129
|
'gray-light': {
|
|
115
|
-
open:
|
|
130
|
+
open: `color: #${styleToHexColor.grayLight}`,
|
|
116
131
|
close: 'color: currentcolor'
|
|
117
132
|
}
|
|
118
133
|
};
|
|
119
|
-
|
|
134
|
+
const styleToHtmlStyleThemeDark = {
|
|
135
|
+
...styleToHtmlStyleThemeLight,
|
|
120
136
|
black: styleToHtmlStyleThemeLight.white,
|
|
121
137
|
bgBlack: styleToHtmlStyleThemeLight.bgWhite,
|
|
122
138
|
white: styleToHtmlStyleThemeLight.black,
|
|
@@ -125,35 +141,29 @@ var styleToHtmlStyleThemeDark = _extends({}, styleToHtmlStyleThemeLight, {
|
|
|
125
141
|
open: 'color: lightgray',
|
|
126
142
|
close: 'color: currentcolor'
|
|
127
143
|
}
|
|
128
|
-
}
|
|
144
|
+
};
|
|
129
145
|
|
|
130
146
|
/* eslint-disable max-lines, @typescript-eslint/no-use-before-define */
|
|
131
147
|
|
|
132
|
-
|
|
133
|
-
return value;
|
|
134
|
-
};
|
|
148
|
+
const noStyleFn = (styles, value) => value;
|
|
135
149
|
function tryStringify(arg) {
|
|
136
150
|
try {
|
|
137
151
|
return JSON.stringify(arg).replace(/\\n/g, '\n');
|
|
138
|
-
} catch
|
|
152
|
+
} catch {
|
|
139
153
|
return '[Circular]';
|
|
140
154
|
}
|
|
141
155
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
stack,
|
|
154
|
-
name,
|
|
155
|
-
_name;
|
|
156
|
-
var typeofValue = typeof value;
|
|
156
|
+
const sameRawFormattedValue = value => ({
|
|
157
|
+
stringValue: value,
|
|
158
|
+
formattedValue: value
|
|
159
|
+
});
|
|
160
|
+
function internalFormatValue(value, styleFn, styles, {
|
|
161
|
+
padding,
|
|
162
|
+
depth,
|
|
163
|
+
maxDepth,
|
|
164
|
+
objects
|
|
165
|
+
}) {
|
|
166
|
+
const typeofValue = typeof value;
|
|
157
167
|
if (!styles) {
|
|
158
168
|
if (value == null) {
|
|
159
169
|
styles = ['cyan'];
|
|
@@ -180,7 +190,7 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
180
190
|
}
|
|
181
191
|
}
|
|
182
192
|
}
|
|
183
|
-
|
|
193
|
+
let stringValue;
|
|
184
194
|
if (value === null) {
|
|
185
195
|
stringValue = 'null';
|
|
186
196
|
} else if (value === undefined) {
|
|
@@ -193,10 +203,10 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
193
203
|
stringValue = '{Object...}';
|
|
194
204
|
} else {
|
|
195
205
|
return internalFormatObject(value, styleFn, undefined, {
|
|
196
|
-
padding
|
|
206
|
+
padding,
|
|
197
207
|
depth: depth + 1,
|
|
198
|
-
maxDepth
|
|
199
|
-
objects
|
|
208
|
+
maxDepth,
|
|
209
|
+
objects
|
|
200
210
|
});
|
|
201
211
|
}
|
|
202
212
|
} else if (Array.isArray(value)) {
|
|
@@ -204,25 +214,25 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
204
214
|
stringValue = '[Array...]';
|
|
205
215
|
} else {
|
|
206
216
|
return internalFormatArray(value, styleFn, {
|
|
207
|
-
padding
|
|
217
|
+
padding,
|
|
208
218
|
depth: depth + 1,
|
|
209
|
-
maxDepth
|
|
210
|
-
objects
|
|
219
|
+
maxDepth,
|
|
220
|
+
objects
|
|
211
221
|
});
|
|
212
222
|
}
|
|
213
223
|
} else if (value instanceof Error) {
|
|
214
|
-
stack = value.stack;
|
|
215
|
-
stringValue = stack != null && stack.startsWith(value.message) || stack != null && stack.startsWith(value.name
|
|
224
|
+
const stack = value.stack;
|
|
225
|
+
stringValue = stack != null && stack.startsWith(value.message) || stack != null && stack.startsWith(`${value.name}: ${value.message}`) ? stack : `${value.message}\n${stack || ''}`;
|
|
216
226
|
} else if (value instanceof Map) {
|
|
217
|
-
name = value.constructor.name;
|
|
227
|
+
const name = value.constructor.name;
|
|
218
228
|
if (depth >= maxDepth) {
|
|
219
|
-
stringValue =
|
|
229
|
+
stringValue = `{${name}...}`;
|
|
220
230
|
} else {
|
|
221
231
|
return internalFormatMap(name, value, styleFn, {
|
|
222
|
-
padding
|
|
232
|
+
padding,
|
|
223
233
|
depth: depth + 1,
|
|
224
|
-
maxDepth
|
|
225
|
-
objects
|
|
234
|
+
maxDepth,
|
|
235
|
+
objects
|
|
226
236
|
});
|
|
227
237
|
}
|
|
228
238
|
} else if (typeofValue === 'bigint') {
|
|
@@ -230,15 +240,15 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
230
240
|
} else if (typeofValue === 'symbol') {
|
|
231
241
|
stringValue = value.toString();
|
|
232
242
|
} else if (value instanceof Set) {
|
|
233
|
-
|
|
243
|
+
const name = value.constructor.name;
|
|
234
244
|
if (depth >= maxDepth) {
|
|
235
|
-
stringValue =
|
|
245
|
+
stringValue = `{${name}...}`;
|
|
236
246
|
} else {
|
|
237
|
-
return internalFormatSet(
|
|
238
|
-
padding
|
|
247
|
+
return internalFormatSet(name, value, styleFn, {
|
|
248
|
+
padding,
|
|
239
249
|
depth: depth + 1,
|
|
240
|
-
maxDepth
|
|
241
|
-
objects
|
|
250
|
+
maxDepth,
|
|
251
|
+
objects
|
|
242
252
|
});
|
|
243
253
|
}
|
|
244
254
|
} else if (value instanceof WeakMap) {
|
|
@@ -248,70 +258,73 @@ function internalFormatValue(value, styleFn, styles, _ref) {
|
|
|
248
258
|
} else {
|
|
249
259
|
stringValue = tryStringify(value);
|
|
250
260
|
}
|
|
251
|
-
|
|
261
|
+
const formattedValue = styleFn(styles, stringValue);
|
|
252
262
|
return {
|
|
253
|
-
stringValue
|
|
254
|
-
formattedValue
|
|
263
|
+
stringValue,
|
|
264
|
+
formattedValue
|
|
255
265
|
};
|
|
256
266
|
}
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
const separator = ',';
|
|
268
|
+
const internalFormatKey = (key, styleFn) => {
|
|
259
269
|
return {
|
|
260
|
-
stringKey: key
|
|
261
|
-
formattedKey: styleFn(['gray-light', 'bold'], key
|
|
270
|
+
stringKey: `${key}: `,
|
|
271
|
+
formattedKey: `${styleFn(['gray-light', 'bold'], `${key}:`)} `
|
|
262
272
|
};
|
|
263
273
|
};
|
|
264
|
-
|
|
274
|
+
const internalNoKey = () => {
|
|
265
275
|
return {
|
|
266
276
|
stringKey: '',
|
|
267
277
|
formattedKey: ''
|
|
268
278
|
};
|
|
269
279
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
stringValue
|
|
273
|
-
formattedValue
|
|
280
|
+
const internalFormatMapKey = (key, styleFn, internalFormatParams) => {
|
|
281
|
+
const {
|
|
282
|
+
stringValue,
|
|
283
|
+
formattedValue
|
|
284
|
+
} = internalFormatValue(key, noStyleFn, undefined, internalFormatParams);
|
|
274
285
|
return {
|
|
275
|
-
stringKey: stringValue
|
|
276
|
-
formattedKey: styleFn(['gray-light', 'bold'], formattedValue
|
|
286
|
+
stringKey: `${stringValue} => `,
|
|
287
|
+
formattedKey: `${styleFn(['gray-light', 'bold'], `${formattedValue}:`)} `
|
|
277
288
|
};
|
|
278
289
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
padding
|
|
290
|
+
const internalFormatIterator = (values, styleFn, objectStyles, {
|
|
291
|
+
padding,
|
|
292
|
+
depth,
|
|
293
|
+
maxDepth,
|
|
294
|
+
objects
|
|
295
|
+
}, {
|
|
296
|
+
prefix,
|
|
297
|
+
suffix,
|
|
298
|
+
prefixSuffixSpace = ' ',
|
|
299
|
+
formatKey
|
|
300
|
+
}) => {
|
|
301
|
+
let breakLine = false;
|
|
302
|
+
const formattedSeparator = () => styleFn(['gray'], separator);
|
|
303
|
+
const valuesMaxIndex = values.length - 1;
|
|
304
|
+
const formattedValues = values.map(({
|
|
305
|
+
key,
|
|
306
|
+
value
|
|
307
|
+
}, index) => {
|
|
308
|
+
const internalFormatParams = {
|
|
309
|
+
padding,
|
|
299
310
|
depth: depth + 1,
|
|
300
|
-
maxDepth
|
|
301
|
-
objects
|
|
311
|
+
maxDepth,
|
|
312
|
+
objects
|
|
302
313
|
};
|
|
303
314
|
|
|
304
315
|
// key must be formatted before value (browser-formatter needs order)
|
|
305
|
-
|
|
306
|
-
stringKey
|
|
307
|
-
formattedKey
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
316
|
+
const {
|
|
317
|
+
stringKey,
|
|
318
|
+
formattedKey
|
|
319
|
+
} = formatKey(key, styleFn, internalFormatParams);
|
|
320
|
+
let {
|
|
321
|
+
stringValue,
|
|
322
|
+
formattedValue
|
|
323
|
+
} = internalFormatValue(value, styleFn, key && objectStyles ? objectStyles[key] : undefined, internalFormatParams);
|
|
311
324
|
if (stringValue && (stringValue.length > 80 || stringValue.includes('\n'))) {
|
|
312
325
|
breakLine = true;
|
|
313
|
-
stringValue = stringValue.replace(/\n/g,
|
|
314
|
-
formattedValue = formattedValue.replace(/\n/g,
|
|
326
|
+
stringValue = stringValue.replace(/\n/g, `\n${padding}`);
|
|
327
|
+
formattedValue = formattedValue.replace(/\n/g, `\n${padding}`);
|
|
315
328
|
}
|
|
316
329
|
return {
|
|
317
330
|
stringValue: stringKey + stringValue + (index === valuesMaxIndex ? '' : separator),
|
|
@@ -319,43 +332,33 @@ var internalFormatIterator = function internalFormatIterator(values, styleFn, ob
|
|
|
319
332
|
// note: we need to format the separator for each values for browser-formatter
|
|
320
333
|
};
|
|
321
334
|
});
|
|
322
|
-
|
|
323
335
|
return {
|
|
324
|
-
stringValue: prefix + formattedValues.map(breakLine ?
|
|
325
|
-
|
|
326
|
-
} : function (fv) {
|
|
327
|
-
return fv.stringValue;
|
|
328
|
-
}).join(breakLine ? '\n' : ' ') + suffix,
|
|
329
|
-
formattedValue: "" + prefix + (breakLine ? '' : prefixSuffixSpace) + formattedValues.map(breakLine ? function (v) {
|
|
330
|
-
return "\n" + padding + v.formattedValue;
|
|
331
|
-
} : function (v) {
|
|
332
|
-
return v.formattedValue;
|
|
333
|
-
}).join(breakLine ? '' : ' ') + (breakLine ? ',\n' : prefixSuffixSpace) + suffix
|
|
336
|
+
stringValue: prefix + formattedValues.map(breakLine ? v => `\n${padding}${v.stringValue}` : fv => fv.stringValue).join(breakLine ? '\n' : ' ') + suffix,
|
|
337
|
+
formattedValue: `${prefix}${breakLine ? '' : prefixSuffixSpace}${formattedValues.map(breakLine ? v => `\n${padding}${v.formattedValue}` : v => v.formattedValue).join(breakLine ? '' : ' ')}${breakLine ? ',\n' : prefixSuffixSpace}${suffix}`
|
|
334
338
|
};
|
|
335
339
|
};
|
|
336
|
-
function internalFormatObject(object, styleFn, objectStyles,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
340
|
+
function internalFormatObject(object, styleFn, objectStyles, {
|
|
341
|
+
padding,
|
|
342
|
+
depth,
|
|
343
|
+
maxDepth,
|
|
344
|
+
objects
|
|
345
|
+
}) {
|
|
341
346
|
if (objects.has(object)) {
|
|
342
347
|
return sameRawFormattedValue('{Circular Object}');
|
|
343
348
|
}
|
|
344
|
-
|
|
349
|
+
const keys = Object.keys(object);
|
|
345
350
|
if (keys.length === 0) {
|
|
346
351
|
return sameRawFormattedValue('{}');
|
|
347
352
|
}
|
|
348
353
|
objects.add(object);
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
maxDepth: maxDepth,
|
|
358
|
-
objects: objects
|
|
354
|
+
const result = internalFormatIterator(keys.map(key => ({
|
|
355
|
+
key,
|
|
356
|
+
value: object[key]
|
|
357
|
+
})), styleFn, objectStyles, {
|
|
358
|
+
padding,
|
|
359
|
+
depth,
|
|
360
|
+
maxDepth,
|
|
361
|
+
objects
|
|
359
362
|
}, {
|
|
360
363
|
prefix: '{',
|
|
361
364
|
suffix: '}',
|
|
@@ -364,42 +367,42 @@ function internalFormatObject(object, styleFn, objectStyles, _ref5) {
|
|
|
364
367
|
objects.delete(object);
|
|
365
368
|
return result;
|
|
366
369
|
}
|
|
367
|
-
function internalFormatMap(name, map, styleFn,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
function internalFormatMap(name, map, styleFn, {
|
|
371
|
+
padding,
|
|
372
|
+
depth,
|
|
373
|
+
maxDepth,
|
|
374
|
+
objects
|
|
375
|
+
}) {
|
|
372
376
|
if (objects.has(map)) {
|
|
373
|
-
return sameRawFormattedValue(
|
|
377
|
+
return sameRawFormattedValue(`{Circular ${name}}`);
|
|
374
378
|
}
|
|
375
|
-
|
|
379
|
+
const keys = [...map.keys()];
|
|
376
380
|
if (keys.length === 0) {
|
|
377
|
-
return sameRawFormattedValue(name
|
|
381
|
+
return sameRawFormattedValue(`${name} {}`);
|
|
378
382
|
}
|
|
379
383
|
objects.add(map);
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
maxDepth: maxDepth,
|
|
389
|
-
objects: objects
|
|
384
|
+
const result = internalFormatIterator(keys.map(key => ({
|
|
385
|
+
key,
|
|
386
|
+
value: map.get(key)
|
|
387
|
+
})), styleFn, undefined, {
|
|
388
|
+
padding,
|
|
389
|
+
depth,
|
|
390
|
+
maxDepth,
|
|
391
|
+
objects
|
|
390
392
|
}, {
|
|
391
|
-
prefix: name
|
|
393
|
+
prefix: `${name} {`,
|
|
392
394
|
suffix: '}',
|
|
393
395
|
formatKey: internalFormatMapKey
|
|
394
396
|
});
|
|
395
397
|
objects.delete(map);
|
|
396
398
|
return result;
|
|
397
399
|
}
|
|
398
|
-
function internalFormatArray(array, styleFn,
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
400
|
+
function internalFormatArray(array, styleFn, {
|
|
401
|
+
padding,
|
|
402
|
+
depth,
|
|
403
|
+
maxDepth,
|
|
404
|
+
objects
|
|
405
|
+
}) {
|
|
403
406
|
if (objects.has(array)) {
|
|
404
407
|
return sameRawFormattedValue('{Circular Array}');
|
|
405
408
|
}
|
|
@@ -407,16 +410,14 @@ function internalFormatArray(array, styleFn, _ref7) {
|
|
|
407
410
|
return sameRawFormattedValue('[]');
|
|
408
411
|
}
|
|
409
412
|
objects.add(array);
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
maxDepth: maxDepth,
|
|
419
|
-
objects: objects
|
|
413
|
+
const result = internalFormatIterator(array.map(value => ({
|
|
414
|
+
key: undefined,
|
|
415
|
+
value
|
|
416
|
+
})), styleFn, undefined, {
|
|
417
|
+
padding,
|
|
418
|
+
depth,
|
|
419
|
+
maxDepth,
|
|
420
|
+
objects
|
|
420
421
|
}, {
|
|
421
422
|
prefix: '[',
|
|
422
423
|
suffix: ']',
|
|
@@ -426,53 +427,48 @@ function internalFormatArray(array, styleFn, _ref7) {
|
|
|
426
427
|
objects.delete(array);
|
|
427
428
|
return result;
|
|
428
429
|
}
|
|
429
|
-
function internalFormatSet(name, set, styleFn,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
430
|
+
function internalFormatSet(name, set, styleFn, {
|
|
431
|
+
padding,
|
|
432
|
+
depth,
|
|
433
|
+
maxDepth,
|
|
434
|
+
objects
|
|
435
|
+
}) {
|
|
434
436
|
if (objects.has(set)) {
|
|
435
|
-
return sameRawFormattedValue(
|
|
437
|
+
return sameRawFormattedValue(`{Circular ${name}}`);
|
|
436
438
|
}
|
|
437
|
-
|
|
439
|
+
const values = [...set.values()];
|
|
438
440
|
if (values.length === 0) {
|
|
439
|
-
return sameRawFormattedValue(name
|
|
441
|
+
return sameRawFormattedValue(`${name} []`);
|
|
440
442
|
}
|
|
441
443
|
objects.add(set);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
maxDepth: maxDepth,
|
|
451
|
-
objects: objects
|
|
444
|
+
const result = internalFormatIterator(values.map(value => ({
|
|
445
|
+
key: undefined,
|
|
446
|
+
value
|
|
447
|
+
})), styleFn, undefined, {
|
|
448
|
+
padding,
|
|
449
|
+
depth,
|
|
450
|
+
maxDepth,
|
|
451
|
+
objects
|
|
452
452
|
}, {
|
|
453
|
-
prefix: name
|
|
453
|
+
prefix: `${name} [`,
|
|
454
454
|
suffix: ']',
|
|
455
455
|
formatKey: internalNoKey
|
|
456
456
|
});
|
|
457
457
|
objects.delete(set);
|
|
458
458
|
return result;
|
|
459
459
|
}
|
|
460
|
-
function formatObject(object, styleFn, objectStyles,
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
maxDepth
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
depth: 0,
|
|
473
|
-
objects: new Set()
|
|
474
|
-
}),
|
|
475
|
-
result = _internalFormatObject.formattedValue;
|
|
460
|
+
function formatObject(object, styleFn = noStyleFn, objectStyles, {
|
|
461
|
+
padding = ' ',
|
|
462
|
+
maxDepth = 10
|
|
463
|
+
} = {}) {
|
|
464
|
+
const {
|
|
465
|
+
formattedValue: result
|
|
466
|
+
} = internalFormatObject(object, styleFn, objectStyles, {
|
|
467
|
+
padding,
|
|
468
|
+
maxDepth,
|
|
469
|
+
depth: 0,
|
|
470
|
+
objects: new Set()
|
|
471
|
+
});
|
|
476
472
|
if (result === '{}') {
|
|
477
473
|
return '';
|
|
478
474
|
}
|
|
@@ -480,7 +476,7 @@ function formatObject(object, styleFn, objectStyles, _temp) {
|
|
|
480
476
|
}
|
|
481
477
|
|
|
482
478
|
function formatRecordToString(record, style) {
|
|
483
|
-
|
|
479
|
+
const parts = [];
|
|
484
480
|
if (record.displayName) {
|
|
485
481
|
parts.push(style(['gray-light'], record.displayName));
|
|
486
482
|
} else if (record.key) {
|
|
@@ -490,12 +486,11 @@ function formatRecordToString(record, style) {
|
|
|
490
486
|
parts.push(style(['gray', 'bold'], record.datetime.toTimeString().split(' ')[0]));
|
|
491
487
|
/* new Date().toFormat('HH24:MI:SS') */
|
|
492
488
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
var styles = record.styles || levelToStyles[record.level];
|
|
489
|
+
let message = record.symbol || levelToSymbol[record.level];
|
|
490
|
+
const styles = record.styles || levelToStyles[record.level];
|
|
496
491
|
if (record.message) {
|
|
497
492
|
if (message) {
|
|
498
|
-
message +=
|
|
493
|
+
message += ` ${record.message}`;
|
|
499
494
|
} else {
|
|
500
495
|
message = record.message;
|
|
501
496
|
}
|
|
@@ -506,11 +501,11 @@ function formatRecordToString(record, style) {
|
|
|
506
501
|
}
|
|
507
502
|
parts.push(message);
|
|
508
503
|
}
|
|
509
|
-
|
|
504
|
+
const formatRecordObject = (key, object, objectStyles) => {
|
|
510
505
|
if (!object) {
|
|
511
506
|
return;
|
|
512
507
|
}
|
|
513
|
-
|
|
508
|
+
const stringObject = formatObject(object, style, objectStyles);
|
|
514
509
|
if (!stringObject) {
|
|
515
510
|
return;
|
|
516
511
|
}
|