Adds StdStore. #12

Open
wants to merge 5 commits into
from

Conversation

Projects
None yet
4 participants
Contributor

cpsubrian commented Oct 23, 2012

Adds support for stdin and stdout.

Uses StdStore as the default when no store is provided.

Allows you do do something like:

// app.js

var log = require('jog')();

log.info('Hello');
log.warn('World');
log.debug('Data', {
  property: 'foo',
  value: 'bar'
});

And then run it like:

$ node app.js 
{"level":"info","type":"Hello","timestamp":1350952923180}
{"level":"warn","type":"World","timestamp":1350952923181}
{"property":"foo","value":"bar","level":"debug","type":"Data","timestamp":1350952923181}

OR

$ node app.js | jog -f --map type
Hello
World
Data

OR

$ node app.js | jog -f --select "_.property === 'foo'"
{ property: 'foo',
  value: 'bar',
  level: 'debug',
  type: 'Data',
  timestamp: 1350953035191 }

You get the picture :)

Contributor

cpsubrian commented Oct 23, 2012

Note: Didn't add test because I'm not sure how you would :) child_process.fork() ?

cpsubrian closed this Oct 24, 2012

cpsubrian reopened this Oct 24, 2012

Contributor

cpsubrian commented Oct 24, 2012

Oops

Contributor

cpsubrian commented Oct 25, 2012

  • Refactored StdStore to accept in/out/err streams (for testing).
  • By default 'error' and 'warn' logs write to stderr and the rest to stdout.
  • redirect options allows you to send all logs to stdout instead.
  • Adds tests for StdStore (adds possible race condition if file or redis access is slow, please take a look).
  • Adds example in examples/stdstore.js so people can play with piping the output to the jog CLI.

I'm starting to get pretty happy with this and was wondering what you though of it.

Contributor

cpsubrian commented Oct 25, 2012

Also, figured I should give you some background on how we will use this:

We run our node processes via upstart, and allow upstart to log stdout/stderr. We have a daemon that aggregates logs across all our nodes.

Adding this store will facilitate viewing logs on the command-line during development, and then in production we can tail the /var/log/upstart/app.log files and pipe them into the CLI for quick filtering and analysis.

Contributor

cpsubrian commented Nov 1, 2012

I created https://github.com/cpsubrian/node-jog-stdstore and I'm using that for now. It handles all my log output needs, however, this would still be really cool to land in jog because you can't pipe stuff into it on the command-line without this PR.

rauchg commented Nov 1, 2012

+1

gjohnson commented Jan 8, 2013

+1

j0ni commented Mar 28, 2014

+1 this would be super useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment