overrustle-logs
v3.0.0
Published
Streaming download of OverRustle logs
Downloads
12
Readme
overrustle-logs
Streaming download of OverRustle logs.
Example
In this example, we get a stream of all destiny.gg
messages from a given date,
"stringify" the parsed objects with ndjson
, and finally pipe to stdout:
var logs = require('overrustle-logs');
var ndjson = require('ndjson');
logs({
channel: 'Destinygg',
date: '2015-10-21'
}).pipe(ndjson.serialize()).pipe(process.stdout);
We can also get messages from a specific user. In this example, we will use the
'data'
event just for the sake of showing how there are many ways to consume
streams in general:
var logs = require('overrustle-logs');
logs({
channel: 'Destinygg',
date: '2015-10-21',
user: 'sztanpet'
}).on('data', function(data) {
console.log(JSON.stringify(data));
});
Installation
$ npm install overrustle-logs
API
var logs = require('overrustle-logs');
logs(opts)
Returns a Readable stream of Objects that each represent a message. opts
is an Object whose properties should be:
opts.channel
: String name of channel to download logs of. This is non-optional.opts.date
: String date. If you are getting the entire logs of a channel, you must provide the year, month, and day. If you are getting the logs for a specific user, you only need to provide year and month. The format should be parseable bymoment
(just use the ISO-8601 standard). This is non-optional.opts.user
: String username of user you want to download logs of. This is optional.
Here is an example of an Object that the stream with emit:
{
timestamp: '2015-10-21T23:59:59.000Z',
user: 'RustleBot',
message: 'YEE'
}