JSON Loggly
A node.js module for Loggly,
espcially optimized for node.js API servers that deal in JSON requests
and responses and uses connect for
middleware management.
When calling res.end(), the json-loggly module will automatically log
the request to Loggly and stdout.
json-loggly can also log custom log messages and support 4 different log
levels: debug, info, warning and error.
Usage
json-loggly is very simple to use. To log requests, simply:
var connect = require('connect');
var loggly = require('json-loggly').init('your-loggly-api-key');
var app = function (req, res) {
req.loggly.logBody(input);
res.loggly.logBody(result);
res.end(JSON.stringify(result));
};
connect()
.use(loggly.middleware())
.use(app)
.listen(8080);
To log a custom log message use the json-loggly methods dbg, inf,
war or err:
var loggly = require('json-loggly').init('your-loggly-api-key');
loggly.inf({
service : 'sendgrid',
msg : 'Sending welcome e-mail to newly created user',
to : { id: user._id, email: user.email }
});
loggly.err("Something bad happened");
License
MIT