Skip to content

Commit

Permalink
Improved value formatting in observable logging (#236579)
Browse files Browse the repository at this point in the history
* Improved value formatting in observable logging

* substr -> substring
  • Loading branch information
hediet authored Dec 19, 2024
1 parent 2ba0803 commit 225d1ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/vs/base/common/observableInternal/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 225d1ca

Please sign in to comment.