![Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack](https://cdn.sanity.io/images/cgdhsj6q/production/6af25114feaaac7179b18127c83327568ff592d1-1024x1024.webp?w=800&fit=max&auto=format)
Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
loggly
Advanced tools
Readme
A client implementation for Loggly in node.js
The node-loggly
library is compliant with the Loggly API. Using node-loggly
is easy for a variety of scenarios: logging, working with devices and inputs, searching, and facet searching.
Before we can do anything with Loggly, we have to create a client with valid credentials. We will authenticate for you automatically:
var loggly = require('loggly');
var client = loggly.createClient({
token: "your-really-long-input-token",
subdomain: "your-subdomain",
auth: {
username: "your-username",
password: "your-password"
}
});
There are two ways to send log information to Loggly via node-loggly. The first is to simply call client.log with an appropriate input token:
client.log('127.0.0.1 - Theres no place like home', function (err, result) {
// Do something once you've logged
});
Note that the callback in the above example is optional, if you prefer the 'fire and forget' method of logging:
client.log('127.0.0.1 - Theres no place like home');
In addition to logging pure strings it is also possible to pass shallow JSON object literals (i.e. no nested objects) to client.log(..) or input.log(..) methods, which will get converted into the Loggly recommended string representation. So
var source = {
foo: 1,
bar: 2,
buzz: 3
};
input.log(source);
will be logged as:
foo=1,bar=2,buzz=3
It is also possible to log complex objects using the new JSON capabilities of Loggly. To enable JSON functionality in the client simply add 'json: true' to the configuration:
var config = {
subdomain: "your-subdomain",
auth: {
username: "your-username",
password: "your-password"
},
json: true
};
When the json flag is enabled, objects will be converted to JSON using JSON.stringify before being transmitted to Loggly. So
var source = {
foo: 1,
bar: 2,
buzz: {
sheep: 'jumped',
times: 10
}
};
input.log(source);
will be logged as:
{ "foo": 1, "bar": 2, "buzz": {"sheep": "jumped", "times": 10 }}
Searching with node-loggly is easy. All you have to do is use the search() method defined on each Loggly client:
var util = require('util');
client.search('404', function (err, results) {
// Inspect the result set
console.dir(results.events);
});
The search() method can also take an Object parameter that allows you to set additional search parameters such as: rows, from, until, etc.
var util = require('util');
client.search({ query: '404', rows: 10 })
.run(function (err, results) {
// Inspect the result set
console.dir(results.events);
});
See the Loggly search guide for more details on how to effectively search through your Loggly logs.
$ curl http://npmjs.org/install.sh | sh
$ npm install loggly
All of the node-loggly tests are written in vows, and cover all of the use cases described above. You will need to add your Loggly username, password, subdomain, and a two test inputs to test/data/test-config.json before running tests. When configuring the test inputs on Loggly, the first test input should be named 'test' using the HTTP service. The second input should be name 'test_json' using the HTTP service with the JSON logging option enabled:
{
"token": "your-really-long-token-you-got-when-you-created-an-http-input",
"subdomain": "your-subdomain",
"auth": {
"username": "your-username",
"password": "your-password"
}
}
Once you have valid Loggly credentials you can run tests with vows:
$ npm test
FAQs
A client implementation for Loggly cloud Logging-as-a-Service API
The npm package loggly receives a total of 52,904 weekly downloads. As such, loggly popularity was classified as popular.
We found that loggly demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.