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

logs-to-logentries

v1.0.0

Published

A simple logentries log client tool

Downloads

2

Readme

logs-to-logentries

A client implementation for Logentries in node.js.

Usage

Very simple.

First of all, set up an account with Logentries

Create a Log which in turn will issue you with a Token.

alt tag

See docs here for HTTP POST too

Now write a few lines of code to call logs-to-logentries:


const Logentries = require('logs-to-logentries');

var logentriesToken = 'YOUR_LOGENTRIES_TOKEN';
// var logentriesToken = '44dabcdef-939b-4caa-829e-e89fghei9316';

// var endpoint = 'YOUR_ENDPOINT';
var endpoint = 'https://webhook.logentries.com/noformat/logs/';

var url = endpoint + logentriesToken;

const logentries = Logentries.createClient({
  url: url
});

var cb = function (err, res) {
  if (err) {
    // handle error
  }
  // handle success
};

// contrived example..

// single log message
var log = {test: "test only"};
logentries.log(JSON.stringify(log), cb);

Optionally, setup a live tail to your Log endpoint

You should see your logs appearing, eg.

Done!

If you are looking for "bulk" extraction of logs to logentries then for the timebeing there is unfortunately a body size restriction on the logentries HTTP Post endpoint:

The maximum number of characters that can be included in the body is 8192, if you exceed this limit then you message will be dropped

To get around this, you could use a library like async.js and cycle through in batches of 5 (series) at a time.

Here is some contrived, basic code on how this might work (here we are creating the logs for demo purposes only too):

var async = require('async');

const Logentries = require('logs-to-logentries');

var logentriesToken = 'YOUR_LOGENTRIES_TOKEN';
// var logentriesToken = '44dabcdef-939b-4caa-829e-e89fghei9316';

// var endpoint = 'YOUR_ENDPOINT';
var endpoint = 'https://webhook.logentries.com/noformat/logs/';

var url = endpoint + logentriesToken;

const logentries = Logentries.createClient({
  url: url
});

async.waterfall([
  (callback) => {
    var logs = [];
    for(var i = 0; i < 100; i++) {
      logs.push({_id: i, message: 'hello world - you are number: ' + i});
    }
    return callback(null, {logs: logs});
  },
  (context, callback) => {
    callback(null, context);
  },
  (context, callback) => {

    async.eachLimit(context.logs, 5, (log, cb) => {
    
      // logentries here...
      logentries.log(JSON.stringify(log), cb);

    }, (err) => {
      if (err) {
        return callback(err);
      }
      console.log('Upload completed.');
      return callback(null, context);
    });

  }
], function (err, context) {
  if (err) {
    return console.log('Job failed.');
  }
  return console.log('Job completed.');
});

You should see your logs appearing, eg.

alt tag

This NPM module does have bulk sending functionality already written but disabled for time-being until logentries support becomes available.