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

logamaton

v0.0.1

Published

JSON logfile automation

Downloads

13

Readme

Flog

Logfile automation for JSON logs.

var logamaton = require('logamaton');

var entries = logamaton({
  readStream: fs.createReadStream('./logs.json'),
});

entries
  .filter(logamaton.filters.all())
  .filter(logamaton.filters.after({
    start: new Date('2014-01-01')
  }))
  .filter(logamaton.filters.has('err'))
  .report(function (results) {
    console.log(results);
  });

Installation

$ npm install logamaton

Filters

Determine whether a given entry from a log is interesting or not. All filters are instrumented to capture a count of all log entries they receive and a copy of all entries they match. They may be defined either as arguments to logamaton:

var filters = [
  logamaton.filters.all(),
  logamaton.filters.after({ start: new Date('2014-03-18T02:14:39.151Z') }),
  logamaton.filters.has('err'),
  logamaton.filters.where({ level: 40 })
];

logamaton({
  readStream: process.stdin,
  filters: filters
});

Or by chaining with filter:

logamaton({ readStream: process.stdin });
  .filter(logamaton.filters.all())
  .filter(logamaton.filters.after({ start: new Date('2014-03-18T02:14:39.151Z') }));

Custom Filters

Custom filters may be built using logamaton.instrument(name, iter):

var fzbz = logamaton.instrument('fzbz', function (data, callback) {
  data.fizz = 'buzz';
  callback(null, data);
});

Reporters

Reporters inspect filter metrics to summarize the contents of the log. They may be defined either as arguments to logamaton:

function aReporter (results) {
  console.log(results.total);
}

logamaton({
  readStream: process.stdin,
  filters: filters,
  reports: [aReporter]
});

Or by chaining with report:

logamaton({ readStream: process.stdin })
  .report(function (results) {
    console.log(results.total);
  })

Reports for an individual function may also be recovered from a specific filter by calling results() on the filter.

var after = logamaton.filters.after({
  start: new Date('2014-03-18T02:14:39.151Z')
});

logamaton({ readStream: process.stdin })
  .filter(after)
  .report(function () {
    console.log(after.results().matches);
  });

TODO

More filtering, more reporting, more analytics. Test coverage. Benchmarking.

Contributing

Have something to add? Contributions are enormously welcome!

  1. Fork this repo
  2. Update the spec and implement the change
  3. Submit a pull request

License

Flog is released under the terms of the JSON license