npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

query-logentries

v1.2.0

Published

Query logentries.com via their REST API

Downloads

11

Readme

query-logentries

npm version Build Status dependencies Status devDependency Status Coverage Status

Query logentries.com via their REST API. Returns only the raw log messages you passed to logEntries at the time of logging. Supports both callback and streaming and uses request-retry-stream internally to make requests in order to be more robust in case of network glitches.

Installation

npm install --save query-logentries

Usage

How to initialize and available options:

const queryLogentriesFactory = require('query-logentries');

// Required. Replace with your API KEY
const apiKey = '6971aef7-998f-4cb2-9613-ddb42b9697b8';

// Optional. Defaults to https://rest.logentries.com/query/logs
const queryUrl = 'https://rest.logentries.com/query/logs';

const queryLogentries = queryLogentriesFactory(apiKey, queryUrl);
const opts = {
	// Required. Set it to the id of the log in logEntries you wish
	// to query
	logId: '7d9ff278-3a6d-4c7a-8e65-df89fd3f5a96',

	// Required. Set it to any valid value or stringDate that can
	//be passed to a javascript Date object
	from: '2017-01-01T00:00:00.000',

	// Optional. If empty will default to now. Set it to any valid
	// value or stringDate that can be passed to a javascript Date
	// object
	to: '2017-01-02T23:59:59.999',

	// Optional. Default to 'where()'. The leql query you wish to
	// query with. Please ensure it is a valid leql query or you
	// get statusCode 400 errors from logEntries.
	query: 'where(method=GET)',

	// Optional. Defaults to 50. How many messages should be
	// retrieved per paging request made to logEntries
	perPage: 50,

	// Optional. Defaults to 30000 (30 seconds). How long should
	//the request wait before it times out
	timeout: 30000,

	// Optional. Defaults to 3000 (3 seconds). How long should
	// this module wait when checking if a query response is
	// finished on logEntries
	pollInterval: 3000
};

After initializing, using it with callback:

queryLogentries(opts, (err, messages) => {
	if (err) {
		return; //TODO handle err
	}
	console.log('messages', messages);
});

After initializing, using it with streaming:

const pump = require('pump');
const through2 = require('through2');
const fs = require('fs');

const logEntriesStream = queryLogentries(opts);
const toStringStream = through2.obj(function(message, enc, callback) {
	this.push(JSON.stringify(message) + '\n');
	callback();
});
const toFileStream = fs.createWriteStream('./result.txt');

pump(logEntriesStream, toStringStream, toFileStream, err => {
	if (err) {
		//TODO handle err
	}
});

License

MIT