简体   繁体   中英

Node.js execution replay log system

I run a simple script doing some job. This script has a log messages scattered throughout the code that are saved in log files upon each execution. If something goes wrong I can open the execution log and look on what stage script has stopped, error occurred, etc. But these messages are literally polluting the code: the more details I want -- the more console.log s I should put into.

And so I thought: what if instead of putting all these log messages, I've simply generated (somehow) an execution log and then "replay" it to see what functions were called and in which sequence? Of course it wouldn't contain all the info to not to be too big, but I think it is possible to collect a reasonable amount of data that would be helpful.

The question is: how to implement it and is there already implementations of this idea? Most likely I'm not the first to "invent" this approach to logging and I just don't know about a projects that already do the exact thing I described here.

node --trace [app]

This provides a reasonably good amount of information: The methods being called, their parameters, and the return value. The call sequences are indexed and indented for easy consumption and readability.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM