-
Notifications
You must be signed in to change notification settings - Fork 735
refactor(logger): deeply nested objects fail to show up in logs. #5984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
09a3b36
5c2cab2
e091dc3
02dde97
8962008
d436022
0f15eb1
12a09a2
5628434
8c27467
67e9d9f
797293f
11f293e
5ad9c7e
5a7014c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { isWeb } from '../extensionGlobals' | ||
| import { InspectOptions as nodeInspectOptions, inspect as nodeInspect } from 'util' | ||
| import { AsyncCollection, toCollection } from './asyncCollection' | ||
| import { SharedProp, AccumulableKeys, Coalesce, isNonNullable } from './tsUtils' | ||
|
|
||
|
|
@@ -297,7 +299,6 @@ | |
| * - depth=2 returns `obj` with its children and their children. | ||
| * - and so on... | ||
| * | ||
| * TODO: node's `util.inspect()` function is better, but doesn't work in web browser? | ||
| * | ||
| * @param obj Object to clone. | ||
| * @param depth | ||
|
|
@@ -329,6 +330,31 @@ | |
| return clonedObj | ||
| } | ||
|
|
||
| type inspectOptions = Partial< | ||
| nodeInspectOptions & { | ||
| omitKeys: string[] | ||
| replacement: any | ||
|
||
| } | ||
| > | ||
|
|
||
| /** | ||
| * Wrapper around nodes inspect function that works on web. Defaults to JSON.stringify on web. | ||
| * @param obj object to show | ||
| * @param opt options for showing (ex. depth, omitting keys) | ||
| */ | ||
| export function inspect(obj: any, opt?: inspectOptions): string { | ||
| const options = { | ||
| depth: opt?.depth ?? 3, | ||
| omitKeys: opt?.omitKeys ?? [], | ||
| replacement: opt?.replacement, | ||
| showHidden: opt?.showHidden ?? false, | ||
| color: opt?.colors ?? false, | ||
| } | ||
| return isWeb() | ||
| ? JSON.stringify(partialClone(obj, options.depth, options.omitKeys, options.replacement), undefined, 2) | ||
| : nodeInspect(obj, options) | ||
| } | ||
|
|
||
| /** Recursively delete undefined key/value pairs */ | ||
| export function stripUndefined<T extends Record<string, any>>( | ||
| obj: T | ||
|
|
@@ -365,7 +391,7 @@ | |
| TResponse, | ||
| TTokenProp extends SharedProp<TRequest, TResponse>, | ||
| TTokenType extends TRequest[TTokenProp] & TResponse[TTokenProp], | ||
| TResult extends AccumulableKeys<TResponse> = never, | ||
| TResult extends AccumulableKeys<TResponse> = never | ||
| >( | ||
| requester: (request: TRequest) => Promise<TResponse>, | ||
| request: TRequest, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.