0

In my express.js project everything works fine, but having several routing files an other function files, I feel a bit like drowning in all the functions, not knowing which functions run, when, and by which caller.

For example, I have two functions that may run too many times in event loop: the router.use which I see as a constructor to all related routes (from which I want to filter out some), and verify token function that should run only when certain conditions are met, such as API calls, or regular calls that detect admin cookie etc.

I'm trying to generate a log that can help me find which functions are called more than once and by which caller. Sort of like a map per event.

I use console.log to see order and current call url when firing an event, and I also use node-inspector's breakpoints to see how many times functions like router.use are called, but when manually following the functions in node-inspector, many node core files are involved in the process, which makes the task more tedious because I am interested to debug only my functions... and it doesn't let me see the bigger picture, more readable information on a zoomed out perspective.

What is the preferable method to generate such a log/report?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Omer Greenwald
  • 758
  • 7
  • 20
  • You can always try the swiss-army-knife method [*at the bottom of this answer*](http://stackoverflow.com/a/27867426/23771). It's not logging, but it does tell you which routines and lines of your code account for the most time. There is a secondary technique of time-stamped logging of message traffic, but the first method is effective and much easier. – Mike Dunlavey Jul 19 '15 at 13:18
  • Thanks Mike. You refer to random pausing? interesting approach but I was actually hoping to find a node module for that...Also, the time stamps are not the main issue, it's more about counting, order and triggers of functions executing. – Omer Greenwald Jul 19 '15 at 20:01

0 Answers0