Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: mute #8

Open
karlpokus opened this issue Jul 3, 2016 · 6 comments
Open

Feature request: mute #8

karlpokus opened this issue Jul 3, 2016 · 6 comments

Comments

@karlpokus
Copy link

Thanks for sharing your module! I'm looking for a way to both intercept and mute the log. By commenting out this line I think it would work.

Would you be interested in a PR or should I fork?

@SimenB
Copy link
Contributor

SimenB commented Jul 13, 2016

Not returning in the interceptor should work, shouldn't it?

@sfarthin
Copy link
Owner

I think SimenB is basically right, you can see the first example (output is muted) in the README compared to the 2nd one under the modification section (the 'intercepter' returns a manipulated string). Although, I think process.stdout.write is still being called regardless, but I am not sure this has an effect.

@karlpokus
Copy link
Author

@SimenB Nor sure what you mean by Not returning in the interceptor. Commenting out captured_text += txt or removing the callback altogether does not work.

@sfarthin But the log is not muted in the first example. The part below logs a and b.

var intercept = require("intercept-stdout"),
    captured_text = "";

var unhook_intercept = intercept(function(txt) {
    captured_text += txt;
});

console.log("a");
unhook_intercept(); // Let's stop capturing stdout.
console.log("b");

Nevermind. I made something that mutes the log (although I think I lost the streaming aspect but that's fine by me).

@fedor
Copy link

fedor commented Sep 29, 2016

@karlpokus correct. @sfarthin was talking about 2nd example in the readme.

It's not obvious from the readme, but after studying tests I realised that to suppress output empty string should be returned (not undefined).

let unhook_intercept = intercept(function (line) {
    // ...
    return ''
})

@sfarthin could be useful to mention that not returning a string will result in print of the original string.

@sfarthin
Copy link
Owner

Sounds good, would you mind doing a PR?

@LaurentGoderre
Copy link

This sort of can be closed. The readme has the info but on the npm site, the changes to the readme are not there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants