From 225d1ca870a984369bde1a7fcd75f863fc69fee1 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Thu, 19 Dec 2024 13:07:00 +0100 Subject: [PATCH] Improved value formatting in observable logging (#236579) * Improved value formatting in observable logging * substr -> substring --- src/vs/base/common/observableInternal/logging.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/vs/base/common/observableInternal/logging.ts b/src/vs/base/common/observableInternal/logging.ts index 0c343b548e47d..a6a5bb78a0698 100644 --- a/src/vs/base/common/observableInternal/logging.ts +++ b/src/vs/base/common/observableInternal/logging.ts @@ -356,6 +356,14 @@ function formatArray(value: unknown[], availableLen: number): string { } function formatObject(value: object, availableLen: number): string { + if (typeof value.toString === 'function' && value.toString !== Object.prototype.toString) { + const val = value.toString(); + if (val.length <= availableLen) { + return val; + } + return val.substring(0, availableLen - 3) + '...'; + } + let result = '{ '; let first = true; for (const [key, val] of Object.entries(value)) {