
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
cantina-log
Advanced tools
JSON-powered logging for Cantina applications. Extends jog with some Cantina-specific functionality.
Setting up your app:
var app = require('cantina').createApp();
app.boot(function (err) {
// Load the logging plugin.
app.require('cantina-log');
// Load the rest of your plugins.
app.start();
});
Start logging...
// Perferred logging method:
app.log('type', {
// data
})
// console.log-style logging.
app.log('My message with %s tokens in it', 'some');
// dump an object.
app.log({my: 'data'});
// Use levels:
app.log.info('type', { /* data */ });
app.log.debug('type', { /* data */ });
app.log.warn('type', { /* data */ });
app.log.error('type', { /* data */ });
The following configuration (defaults shown) is supported.
{
log: {
trace: true,
req: {
enable: true,
exclude: /(\.js$)|(\.css$)|(\/images.*)|(favicon.ico)|(\.hbs$)/
}
}
}
app.log.replaceConsole()
- Override console's logging methods with app.log
variants.app.log.restoreConsole()
- Restore console to its orginal state.jog logs using a 'store'. The default is StdStore
which logs to stdout
and stderr. If you prefer to use a FileStore
, RedisStore
, or something
custom you can tell the app like so:
var app = require('cantina').createApp()
, jog = require('jog2');
app.boot(function (err) {
// Pre-log app setup.
// Specify your store.
app.loggerStore = new jog.FileStore('/tmp/log');
// Load the logging plugin.
app.require('cantina-log');
// Load the rest of your plugins.
app.start();
});
You may find yourself logging simliar kinds of application object, such as 'user' models. You can log the raw user objects and implement a serializer to santize it for the logs.
app.hook('log:serialize').add(function (data, next) {
if (data.user) {
var user = data.user;
data.user = {
id: user.id,
name: user.first + ' ' + user.last,
// ... etc.
};
}
next();
});
Now that your log output is in nice, parseable JSON, you may want to be able to read it on the command-line in a more human-friendly format. Joli is a CLI that helps you format newline-separated JSON object (like the ones cantina-log outputs).
Please see joli's README for full documentation.
Terra Eclipse, Inc. is a nationally recognized political technology and strategy firm located in Santa Cruz, CA and Washington, D.C.
FAQs
JSON logging for Cantina apps
We found that cantina-log demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.