
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
debug-trace
Advanced tools
Adds a handy `trace` flag to the console object to prepend the file and line number
This fork of console-trace adds the following features:
console.format
e.g.: // overridable console string prefix formatting function
console.format = function(c) {
return c.date + ": " + c.method + " [" + c.filename + ":" + c.getLineNumber() + "] " + c.functionName;
}
log
, error
ect.Extends the native Node.JS console
object to prefix logging functions
with the CallSite information.
To read more about runtime stack trace introspection you can refer to this article.
$ npm install debug-trace
require('debug-trace')([options])
Boolean
: defaults to false) always print the callsite info even without accessing methods from the t
or traced
getters.String
: defaults to process.cwd()
) the path that will be stripped from the callsite infoBoolean|Object
: defaults to undefined
) terminal colors support flag or a custom color objectBoolean
: defaults to false) callsite alignment flag, when true prints infos on the rightString
: defaults to 'YYYY.MM.DD HH:mm:ss.SSS') date time format with moment().format(...)
require('debug-trace')
You can add the t
or traced
getter to your calls to obtain a stacktrace:
console.t.log('a');
console.traced.log('a');
You can also make every console call trace:
require('debug-trace')({
always: true,
})
...
console.log('a'); // tracing
console.error('a'); // tracing
You can align the callsite infos to the right
require('debug-trace')({
always: true,
right: true
})
...
console.log('a'); // tracing right
console.error('a'); // tracing right
You can change defaults colors too
require('./debug-trace')({
always: true,
colors: {
warn: '35',
info: '32'
}
})
...
console.warn('a'); // magenta
console.info('a'); // green
To customize the string that's prefixed to the calls, override the
console.traceFormat
function.
If you have more sophisticated logging needs, or don't wish to extend
console
, I suggest you look at tracer.
I only added some functionality to the original console-trace:
MIT License
FAQs
Adds a handy `trace` flag to the console object to prepend the file and line number
The npm package debug-trace receives a total of 414 weekly downloads. As such, debug-trace popularity was classified as not popular.
We found that debug-trace demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.