
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Specialized circular buffer for Node.js high performance logging: It buffers log entries in memory and flushes the data to a callback function later. Triggered by size threshold or time interval.
Specialized circular buffer for Node.js high performance logging: It buffers log entries in memory and flushes the data to a callback function later. Triggered by size threshold or time interval.
npm install logbuffer
Example:
const logBuffer = require('logbuffer');
// Set capacity to 100 entries
const capacity = 100;
// Set autoflush (optional)
const autoflush = {
enabled: true,
callback: (data) => {
console.log( `autoflush'd: ${ JSON.stringify(data, null, 4) }` );
},
interval: 15000
}
// Create logBuffer object
let lb = new logBuffer(capacity, { autoflush: autoflush });
// Add log entry
lb.add( {message: 'Logged!', ts: new Date().getTime()} );
setTimeout( () => {
// Add another log entry
lb.add( {message: 'Logged again!', ts: new Date().getTime()} );
}, 2500);
If autoflush is enabled, the callback function is triggered as soon as the buffer is filled up. The data is flushed to the callback function, the buffer starts empty again.
If an interval is set and the capacity is not reached within the time limit, the same as described above happens and the interval is restarted.
For our "Example" that means: flush all data to the callback function when the buffer holds 100 entries or if 15 seconds are over - whatever occurs first.
Returns the overall capacity of the buffer.
Example:
console.log( lb.capacity() );
// 100
Returns the current filling level of the buffer.
Example:
console.log( lb.size() );
// 2
Adds a log entry to the buffer.
You can add strings and/or objects - but don't forget to handle them correctly
when you get the data back!
Example:
let res = lb.add('This is a log line.');
console.log( res );
// OK
Flushes current data and empties the buffer.
Example:
let data = lb.flush();
console.log( JSON.stringify(data, null, 4) );
/*
[{
"message": "Logged!",
"ts": 1473177268820
}, {
"message": "Logged again!",
"ts": 1473177271335
}]
*/
FAQs
Specialized circular buffer for Node.js high performance logging: It buffers log entries in memory and flushes the data to a callback function later. Triggered by size threshold or time interval.
We found that logbuffer 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.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.