oven-sh / bun

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

Browser-like console.log behaviour #4310

Open codehz opened 1 year ago

codehz commented 1 year ago

What is the problem this feature would solve?

like https://examples.deno.land/color-logging

  1. Some libraries which designed for browser environment using css to style logging
  2. I think it is very useful for debugging, can be addition to default log behaviour

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

same as deno: https://examples.deno.land/color-logging

What alternatives have you considered?

Implemented as a polyfill library?

sirenkovladd commented 1 year ago

You can use https://github.com/chalk/chalk

codehz commented 1 year ago

You can use https://github.com/chalk/chalk

It is not a same thing, I want to use same code/library between server and client, and it is not ideal to use different logger implementation.

Chrome's console.log provide a good interface for styling (and it is also works in Safari)

and I found the spec for it: https://console.spec.whatwg.org/#console-namespace

Jarred-Sumner commented 1 year ago

we probably should support it, but i'm hesitant to recommend css-like styling for terminals as a good idea or good api

codehz commented 1 year ago

recommend css-like styling for terminals as a good idea or good api

the only reason is, some libraries are already abusing them. Porting some libraries could be easier if this is supported (or even simply ignoring %c, but consuming the corresponding arguments)