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...
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