oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.46k stars 2.78k forks source link

Adjustable console.log Depth #5938

Open Autumnlight02 opened 1 year ago

Autumnlight02 commented 1 year ago

What is the problem this feature would solve?

I sometimes have strongly nested Objects I need to debug, and when Bun console.logs showed an depth of 8, it was easier to work with.

What is the feature you are proposing to solve the problem?

Basically having a optional flag which can override the default console.log depth from 2 to a number between 1 to 8

What alternatives have you considered?

Technically JSON.stringify is a solution and porting it to a file but that slows things down

PabloSzx commented 10 months ago

so basically

import { inspect } from 'node:util';

inspect.defaultOptions.depth = Infinity;

does not work?

image

maybe this should be updated as well then

PeterlitsZo commented 10 months ago

porting

Not work to me. (Bun 1.0.25, on MacOS)

woxxo commented 10 months ago

It seems to be only one option at the moment:

console.log(JSON.stringify(deeplyNestedObject, null, 2)); // Specify '2' for the depth level
Perodactyl commented 2 months ago

What I want with this is to have the same as bun's highlighted console.log output (for example booleans are yellow and strings are green) but at a higher depth. AFAIK, inspect doesn't give that, and JSON.stringify certainly doesn't either.