Skip to content

Instantly share code, notes, and snippets.

@D3f0
Created October 2, 2019 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save D3f0/d6751425e8090d3a5098e5862ac60cfd to your computer and use it in GitHub Desktop.
Save D3f0/d6751425e8090d3a5098e5862ac60cfd to your computer and use it in GitHub Desktop.
Trace nodejs scripts
// Add this to your index.js, you may want to do file $(which program) to find where
// the package has been installed. Also, you will need to install npm install njstrace
if (process.env.TRACE || false) {
// Generate the name of the tracefile
let call_argument_list = process.argv.slice(2);
call_argument_list.push(new Date().getTime());
let trace_file_name = call_argument_list.join('-');
// File to ouput to, more options in https://www.npmjs.com/package/njstrace
var fileFormatter = {
stdout: `${trace_file_name}.out`,
inspectArgsMaxLen: 0,
indentationChar: '\t'
};
var njstrace = require('njstrace').inject({
formatter: [fileFormatter]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment