Skip to content

Commit d436022

Browse files
committed
rename to formatObj
1 parent 8962008 commit d436022

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

packages/core/src/codewhispererChat/controllers/chat/controller.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { uiEventRecorder } from '../../../amazonq/util/eventRecorder'
5353
import { globals } from '../../../shared'
5454
import { telemetry } from '../../../shared/telemetry'
5555
import { isSsoConnection } from '../../../auth/connection'
56-
import * as util from 'util'
56+
import { formatObj } from '../../../shared/utilities/collectionUtils'
5757

5858
export interface ChatControllerMessagePublishers {
5959
readonly processPromptChatMessage: MessagePublisher<PromptMessage>
@@ -652,7 +652,7 @@ export class ChatController {
652652
const request = triggerPayloadToChatRequest(triggerPayload)
653653
const session = this.sessionStorage.getSession(tabID)
654654
getLogger().info(
655-
`request from tab: ${tabID} conversationID: ${session.sessionIdentifier} request: ${util.inspect(request, { depth: 12 })}`
655+
`request from tab: ${tabID} conversationID: ${session.sessionIdentifier} request: ${formatObj(request, { depth: 12 })}`
656656
)
657657
let response: MessengerResponseType | undefined = undefined
658658
session.createNewTokenSource()
@@ -678,7 +678,7 @@ export class ChatController {
678678
getLogger().info(
679679
`response to tab: ${tabID} conversationID: ${session.sessionIdentifier} requestID: ${
680680
response.$metadata.requestId
681-
} metadata: ${util.inspect(response.$metadata, { depth: 12 })}`
681+
} metadata: ${formatObj(response.$metadata, { depth: 12 })}`
682682
)
683683
await this.messenger.sendAIResponse(response, session, tabID, triggerID, triggerPayload)
684684
} catch (e: any) {

packages/core/src/shared/utilities/collectionUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ type inspectOptions = Partial<{
343343
* @param obj object to show
344344
* @param opt options for showing (ex. depth, omitting keys)
345345
*/
346-
export function inspect(obj: any, opt?: inspectOptions): string {
346+
export function formatObj(obj: any, opt?: inspectOptions): string {
347347
const options = {
348348
depth: opt?.depth ?? 3,
349349
omitKeys: opt?.omitKeys ?? [],

packages/core/src/test/shared/utilities/collectionUtils.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
joinAll,
3232
isPresent,
3333
partialClone,
34-
inspect,
34+
formatObj,
3535
} from '../../../shared/utilities/collectionUtils'
3636

3737
import { asyncGenerator } from '../../../shared/utilities/collectionUtils'
@@ -699,18 +699,18 @@ describe('CollectionUtils', async function () {
699699
})
700700

701701
it('defaults to a depth of 3', function () {
702-
assert.strictEqual(inspect(testData), '{ root: { A: { B: {} } } }')
702+
assert.strictEqual(formatObj(testData), '{ root: { A: { B: {} } } }')
703703
})
704704

705705
it('allows depth to be set manually', function () {
706706
assert.strictEqual(
707-
inspect(testData, { depth: 6 }),
707+
formatObj(testData, { depth: 6 }),
708708
"{\n root: {\n A: {\n B: { C: { D: { E: 'data' } } }\n }\n }\n}"
709709
)
710710
})
711711

712712
it('omits keys specified', function () {
713-
assert.strictEqual(inspect(testData, { omitKeys: ['D', 'C'] }), '{ root: { A: { B: {} } } }')
713+
assert.strictEqual(formatObj(testData, { omitKeys: ['D', 'C'] }), '{ root: { A: { B: {} } } }')
714714
})
715715
})
716716

0 commit comments

Comments
 (0)