seanmonstar

Jun 4 2014
Feb 11 2014

intel v0.5

intel is turning into an even more awesome logging framework than before, as if that was possible! Today, I released version 0.5.0, and am now here to hawk it’s newness. You can check out the full changelog yourself, but I want to highlight a couple bits.

JSON function strings

intel.config is really powerful when coupled with some JSON config files, but Formatters and Filters were never 100% in config, because you could pass a custom function to either to customize to your little kidney’s content. It’s not possible to include typical functions in JSON. Much sad face. So, the formatFn and filterFn options allow you to write a function in a string, and intel will try to parse it into a function. Such JSON.

Logger.trace

A new lowest level was introduced, lower than even VERBOSE, and that’s TRACE. Likewise, Logger.trace behaves like console.trace, providing a stack trace with your message. If you don’t enable loggers with TRACE level logging, then no stacks will be traced, and everything will choo-choo along snappy-like.

Full dbug integration

This is the goods. intel is an awesome application logging library, since it lets you powerfully and easily be a logging switchboard: everything you want to know goes everywhere you want. However, stand-alone libraries have no business deciding where logs go. Libraries should simply provide logging when asked to, and shut up otherwise. That’s why libraries should use something like dbug. Since v0.4, intel has been able to integrate somewhat with dbug, but with 0.5, it can hook directly into it, meaning less bugs, and better performance. Examples!

// hood/lib/csp.js
var dbug = require('dbug')('hood:csp');

exports.csp = function csp(options) {
    dbug('csp options:', options);
    if (!options.policy) {
        dbug.warn('no policy provided. are you sure?');
    }
    // ...
};

// myapp/server.js
var intel = require('intel');
intel.console({ debug: 'hood' });
// will see: 'myapp.node_modules.hood.csp:DEBUG csp options: {}'

Dare I say, using intel and dbug together gives the best logging solution for libraries and apps.

Jan 21 2014
Jan 2 2014

syslogger

When recently writing an intel-syslog library, I noticed that somehow, npm was lacking a sane syslog library. The popular one, node-syslog, is a giant singleton, meaning it’s impossible to have more than one instance available. That felt wrong. Plus, it’s a native module, and for something so simple, I’d rather not have to compile anything.

That’s where syslogger comes in. It’s pure JavaScript, and has a simple API to allow you to create as many instances as you’d like.

var SysLogger = require('syslogger');
var logger = new SysLogger({
  name: 'myApp',
  facility: 'user',
  address: '127.0.01',
  port: 514
});

logger.log(severity, message);
// or
logger.notice(message); //etc

Enjoy.

+

intel 0.4

I released v0.4 of intel last month, but never got around to writing up what’s new.

debug/dbug

I started out all this logging business claiming we should console.log() all the things. intel can easily handle any libaries using console.log. However, I started to see how frustrating it could be for libraries to be spilling logs all over stdout without being asked. dbug is a utility for libraries to provide logging, but to be quiet by default.

intel v0.4 includes the ability to play nice with dbug (and debug). You can call intel.console({ debug: someStr }) to turn on dbug in libraries matching your string. Due to how debug works, by checking an environment variable right when it is required, you’ll need to run intel.console() before requiring any library that uses debug.

performance

As with every release, things get faster. According to meaningless benchmarks, we’re now ~2x faster than winston. Whatever that means.

syslog

Not part of the actual release, but released at the same time, is an intel-syslog library. This provides a simple syslog handler that you can easily use in your app.

require('intel').config({

  handlers: {
    'syslog': {
      'class': 'intel-syslog',
      'address': '127.0.0.1',
      'facility': 'user' //etc...
    }
  },

  loggers: {
    'myapp': {
      'handlers': ['syslog']
    }
  }

});

I’ve created a wiki page to contain handlers such as intel-syslog that work with intel. If you create or find a library for intel, please add it to the list so we all can be happier logging things.

Dec 16 2013
Dec 11 2013
Nov 8 2013

hood

It’s dangerous on the internet, use some security headers. No, really. If you’re making a webapp, you need some of them lovely headers. Headers such as CSP, HSTS, X-Frame-Options. I previously implemented these in our Gmail Bridge, and then needed them again in another app. Copy over the headers code? Nonsense! That’s what libraries are for.

hood

hood

You can use hood without any configuration, and it will use sane defaults that most apps will want to enforce security-wise. You can also pass options to hood(options) to configure parts to be different than default, or you can use each header individually, such as hood.csp().

Included middlewares:

  • csp
  • hsts
  • xframe
  • nosniff

Why didn’t I just use Helmet?

  • helmet doesn’t by default use the Content-Security-Policy header for it’s csp middleware, which is now the standard.
  • I only expected to setup the middleware once, so needing to do pre-setup for helmet.csp by adding and configuring policies felt wrong. hood.csp just accepts policy options, so you can use it once and be done.

v0.1.1

Cover your head, v0.1.1.

Nov 5 2013

client-sessions v0.4.0

We released v0.4.0 of client-sessions today, despite all the npm bumpiness. Here’s the changelog:

  • add activeDuration with default to 5 minutes
  • add checking for native Proxy before using node-proxy
  • add cookie.ephemeral option, default false
  • add constant-time check
  • adds self-aware check. wont override req.session if already exists
  • fix wrong handled of utf8 replacement character
  • fix http expiry of cookie to match duration
  • fix updating cookie expiry whenever duration/createdAt changes
Page 1 of 2