Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify console.trace depth

Tags:

node.js

Is there a way of specify stack trace depth when using console.trace? I would find this particularly useful for info and log level messages to identify line number and file

like image 215
Mark Nguyen Avatar asked Jun 15 '12 11:06

Mark Nguyen


1 Answers

You can control how many stack frames are collected by setting the variable

Error.stackTraceLimit

Setting it to 0 will disable stack trace collection. Any finite integer value will be used as the maximum number of frames to collect. Setting it to Infinity means that all frames will be collected.

Another option is to use the command-line flag --stack-trace-limit:

node --stack-trace-limit=50 test.js

References:

http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi

like image 154
Skomski Avatar answered Nov 04 '22 00:11

Skomski