dop251 / goja_nodejs

Nodejs compatibility library for Goja
MIT License
336 stars 81 forks source link

Update the console module to behave similarly as in Node.js #60

Closed ganigeorgiev closed 1 year ago

ganigeorgiev commented 1 year ago

The default Go logger always print to stderr.

This PR changes the default console module printer to use stdout or stderr similarly as in Node.js. It also adds the console.info and console.debug aliases.

Based on the Node.js console module docs:

The existing Printer interface is not modified to minimize the breaking changes, but still in some situations this could be a breaking change if someone relies on the existing logs destination, so I will understand if you don't want to merge it.

Just to for more context, this was reported in https://github.com/pocketbase/pocketbase/discussions/3024#discussioncomment-6591840 as the user wasn't expecting the console.log messages to end up in their stderr file.