-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Open
Labels
bun.jsSomething to do with a Bun-specific APISomething to do with a Bun-specific APIenhancementNew feature or requestNew feature or request
Description
What is the problem this feature would solve?
I have a piece of code where a method writes to the standard output using console.log
and when a condition is met, it should instead write to a file.
I have no control over the implementation of the method, so I am looking for ways to redirect the console.log
and console.error
calls.
I tried doing this:
const file = Bun.file('file-name.ext');
Bun.stdout = file;
Bun.stderr = file;
method(); // Calls `console.log` inside
However the standard output and standard error streams remained the terminal-attached ones, the file was created, but remained empty.
What is the feature you are proposing to solve the problem?
Make Bun.stdout
and Bun.stderr
read-write and respect the overriden values when using these internally as sinks for console
methods. (But this should probably also affect process.stdout
and process.stderr
maybe?
What alternatives have you considered?
No response
Metadata
Metadata
Assignees
Labels
bun.jsSomething to do with a Bun-specific APISomething to do with a Bun-specific APIenhancementNew feature or requestNew feature or request