2

First stackoverflow question! I am trying to capture all console.log() output from a node.js server. Assume I am on a linux machine and I cannot edit the server's code, (project leader's request). I can, however change how I start the server (node --debug server.js) and I can attach shell scripts. My intent is to pipe the console output into another socket.io server.

I am thinking the only obvious solutions are to either write a linux command to pipe output of the server into something or node.js has a tricky --debug method to output the information.

End result, I want to be able to run the server and pipe the console output to a API testing server. That way, a tester would be able to see, streaming, the output of the server in correlation to the response JSON objects from the API end points.

Thanks, I would love to hear your solutions...

1 Answer 1

2

Answered over IRC, if anyone's interested:

<shesek> patrickm, can't you just pipe the output to another script?
<shesek> node server.js | node send-logs-to-somewhere.js
<shesek> patrickm, in send-logs-to-somewhere.js, you can just read from process.stdin
<patrickm> :)
<patrickm> thats easy
Sign up to request clarification or add additional context in comments.

2 Comments

That's awesome, I didn't know that was possible. send-logs-to-somewhere.js just keeps listening for input?
yea it works beautifully. i open a socket.io connection, open stdin, let the magic happen.

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.