
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
backtrace-logging
Advanced tools
Hide unnecessary logs¹ until an error² occurs.
Loosely based implementation of http://www.exampler.com/writing/ring-buffer.pdf
console.debug/warn
in Browser/Node, util.debug
and optionally process.stdout/err
in Node.window.on(error)
in Browser, process.on(uncaughtException, exit)
in Node.npm install backtrace-logging
Just import this in NodeJS and all your console.debug
and console.warn
logs will be buffered (upto capacity=10
) until the end (process.on(error)
):
import 'backtrace-logging/node.js'
Or this in the browser with some customizations:
import 'backtrace-logging/browser.js?console=log,debug,warn&capacity=10'
Replace …/node.js
with …/browser.js
accordingly.
import BacktraceLogging from 'backtrace-logging'
const bl = new BacktraceLogging(opts)
opts.capacity
[number=10]
How many messages to bufferopts.queue
[Queue]
Custom queue for fn-bufferopts.store
[Map]
Custom map to store { original => patch }
function pairsPatch a function to buffer its calls
bl.fn(fn, opts)
fn
<function>
Function to patchopts
[object]
options for fn-bufferExample:
console.log = bl.fn(console.log)
Patch an object's key method with the patched function
bl.object(object, key, opts)
object
<object>
Object to patchkey
<string>
Key to patch in the object
opts
[object]
options for fn-bufferExample:
bl.object(console, 'log')
Get the original function of the patched function back
bl.get(patch)
patch
<function>
The patched functionExample:
console.log = bl.get(console.log) // restored
Flush the queue
bl.flush()
?auto=false
must be passed to disable auto-registration
import { register } from 'backtrace-logging/node.js?auto=false'
register(meta, opts = meta.opts)
meta.util
[boolean]
Patch util.debugmeta.process
[array]
Keys to patch in process (stdout|stderr
)meta.file
[string]
File to append skipped logs toRequiring …/node.js
without ?auto=false
calls the register
helper function automatically with meta
options parsed from import.meta.url.
Pass the values of meta
object as a URL query string.
Arrays must be passed as comma-separated values.
import 'backtrace-logging/browser.js?console=log,debug,warn&capacity=10'
FAQs
Hide unnecessary logs until an error occurs
The npm package backtrace-logging receives a total of 0 weekly downloads. As such, backtrace-logging popularity was classified as not popular.
We found that backtrace-logging 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
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.