Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
connect-loggly
Advanced tools
Readme
A loggly logger middleware for connect.
This is a small piece of middleware to help you log important information about a request to loggly using their JSON api.
npm install connect-loggly --save
You must construct the loggly client in JSON mode with json: true
in the loggly config.
var logglyClient = require('loggly').createClient(myLogglyConfig) // Make sure json: true in config!
, connectLoggly = require('connect-loggly');
// If you are using express (otherwise just say `connect`)
express.use(connectLoggly(logglyClient))
You can change what the default message looks like. Like connect.logger()
, this middleware deals in tokens which can be customly added using the token
function. First, lets see how we can add new tokens:
// Lets add some tokens!
// A user-id from the req.user object (this would work for mongoose/passport)
connectLoggly.token('user-id', function (req) {
return req.user && req.user._id;
});
// A custom field from the session
connectLoggly.token('session', function (req, res, field) {
return req.session && req.session[field];
});
And now we can change what the logged JSON is. We pass in an token-list, an object of keys which are token names or static fields. The token-list fields' values are replaced with token values from the request and response and sent as a JSON object. Some tokens (req
and res
in the default set) accept parameters as a field, these are the token-list values.
var logglyRequestTokens = {
// Default fields
url: true,
method: true,
'response-time': true,
date: true,
status: true,
'user-agent': true,
'http-version': true,
// Custom headers
'req': 'Accepts',
'res': 'Location',
// Custom tokens (see above)
'user-id': true,
'session': 'someFieldInTheSession',
// Static information
'server-instance': 'abc123'
};
express.use(connectLoggly(logglyClient, logglyRequestTokens));
Note: Just be sure to add all custom tokens BEFORE setting up the middleware.
See LICENSE file
FAQs
loggly logging middleware for connect
The npm package connect-loggly receives a total of 2 weekly downloads. As such, connect-loggly popularity was classified as not popular.
We found that connect-loggly 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.