Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including eel with all npm packages installed. Try it out:

var eel = require("eel")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

eel v0.1.1

EventEmitter logging. It's simple, extensible, and convenient.

eel - EventEmitter Logging Build Status

eel is a logging "framework" that hopes to embody a few simple principles:

  1. Logging should be easy.
  2. Logs should record structured data.
  3. Logging should be flexible.

It accomplishes these goals by decoupling the logging of events from the writing of logs in the simplest way possible: using an EventEmitter


The eel module exports a function that logs at the "info" level:

log = require('eel')
version = require('./package.json').version
log("Started up", {version: version, port: port})

To log at another level, use the log[level] functions:

process.on('uncaughtException', function (err) {
  log.error("uncaughtException", {err: err})

The default levels are debug, info, warning, error, and critical.

Structured Data

Eel uses the logstash JSON event format internally. Every logging method takes a @message as the first parameter, and an object representing the @fields part of a event as the second. Either parameter can be omitted, and if you include any of the @ prefixed "metadata" fields in the field data object they will override the defaults.

Confused? Hopefully these examples will clarify:

log('Something happened', {count: 10})
{ '@message': 'Something happened',
  '@tags': [],
  '@fields': { level: 'info', count: 10 },
  '@timestamp': '2012-12-16T05:44:48.125Z' }

log.warn('Something happened', {count: 10, '@tags': ['bad']})
{ '@message': 'Something happened',
  '@tags': ['bad'],
  '@fields': { level: 'warn', count: 10 },
  '@timestamp': '2012-12-16T05:44:48.125Z' }

log.error('Something happened', {'@message': 'Overridden!'})
{ '@message': 'Overridden!',
  '@tags': [],
  '@fields': { level: 'error' },
  '@timestamp': '2012-12-16T05:44:48.125Z' }

Be careful, Eel doesn't go out of it's way to prevent you from generating garbage log entries!


In addition to the various logging methods, the eel object also acts like an EventEmitter. In fact, none of the above examples produce any output, because nothing is listening to the events being emitted. To rectify this we can attach the simplest possible logging backend to the 'entry' event:

log.on('info', console.log).on('error', console.error)

Now our prepared log entry objects will be printed to the console:

log('Something happened', {relephant: 'data'})
/* Actually prints this to the console:
{ '@message': 'Something happened',
  '@fields': { level: 'info', relephant: 'data' },
  '@timestamp': '2012-05-31T23:49:01.523Z' }

Logging backends

To configure a backend use log.backends.configure with a URI describing the backend and it's options. Logging to a file:


you write your own let me know or send me a pull request to add it to the list:

  • eel-stream - Write logs to a stream (file, tcp socket, whatever) using a formatter function.
  • eel-amqp - Send logs to an AMQP server.


Investigate using EventEmitter2 for namespacing and pattern matching log events.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free