0

I'm working on a Node app at the moment, and one of the modules I'm including has loads of util.debug() and util.log() messages from the util module peppered around it. I would like to suppress the CLI output of these methods without hacking the contrib module itself- is there any easy way of doing this?

I believe these methods write to stderr, but I don't want to suppress all error messages, just those specific ones. Any help is appreciated!

2
  • What module are you using? I'd highly suggest contacting the author about removing those (possibly with a patch that removes them for them). Also, check for a verbosity flag, the default should definitely not be verbose though. Commented Feb 19, 2014 at 2:04
  • This: github.com/rollbar/node_rollbar (notably in lib/api.js) - I have spoken to the authors before, so I may be able to suggest/pull request it, but I was just curious as to whether there was a way of over-riding the output of util after it's already been required/initialised... Commented Feb 19, 2014 at 2:13

1 Answer 1

1

After briefly reviewing the code of node_rollbar, it does not seem like it has a verbosity setting unless there is something configurable for the util module that I am not aware of. It does seem like all cases except 1 are only for error based scenarios.

I agree that contacting the author or better yet submitting a pull request with an adequate solution would be best. However, one approach that is not a great idea is utilizing a dependency injection module like rewire to overwrite the use of util within the node_rollbar module.

Sign up to request clarification or add additional context in comments.

2 Comments

I can't imagine there'll be many responses to this question, so for now at least I'll accept your answer (thanks!). The rewire module looks interesting, +1 for that- although it's still a rather dodgy method. Do you know of any way of suppressing stderr output in general whilst running a node js application, by the way?
Not particularly, though I do know that the forever module lets you output stdout and stderr separately. I want to say that stdout may have also included stderr but I can't recall. There may be some logging modules that can tackle this, but me not sure.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.