Created
October 2, 2019 05:59
-
-
Save D3f0/d6751425e8090d3a5098e5862ac60cfd to your computer and use it in GitHub Desktop.
Trace nodejs scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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