The JavaScript blog.


libraries console logging modules

Logdown: Generate Logs with Markdown

Posted on .

A few years ago, Firefox and Chrome added support for styles to log messages. This means you can call console.log with an additional CSS option. I've noticed a few libraries and frameworks using this to good effect for debugging messages, but an idea that's new to me is combining Markdown with logging.

Logdown (GitHub: caiogondim/logdown, License: MIT, npm: logdown) by Caio Gondim is a module that lets you include Markdown in logs for both the browser and server. It can do the basics, like italic and bold, but the thing that I really like is including code.

To use it, instantiate a new Logdown instance, and then just log as you would with console.log:

var Logdown = require('logdown');  
var debug = new Logdown({ prefix: 'foo' });

debug.log('lorem *ipsum*');  
debug.info('dolor _sit_ amet');  
debug.warn('consectetur `adipiscing` elit');  

The module supports various options: you can turn off Markdown parsing and add a prefix. It supports Node 0.10+, io.js 1.0+; and Chrome, Firefox, IE 9+, Opera, and Safari 8.0+.


tutorials node logging windows windows-and-node

Windows and Node: Event Logs

Posted on .

To read previous posts in this series, view the windows-and-node tag.

Windows has event logs with three categories: System, Application, and Security. These are known as "sources" in Windows terminology, and since NT 4.0 it's been possible to create custom sources as well. Pretty much every version of Windows I've ever seen has included an Event Viewer utility, which can be used to view and manipulate logs.

Event logs are useful in Windows for the same reasons as syslog in Unix. Logging messages from background services is one of the most obvious examples, particularly as Node seems like a promising platform for developing Windows services.

In Node this requires an addon, because native bindings are needed to communicate with the eventlog service. Windows Event Log Js (GitHub: jfromaniello / windowseventlogjs, License: MIT, npm: windows-eventlog) by José F. Romaniello is one such addon.

On a related note, José has also written a great tutorial on how to create Node addons for Windows using Visual Studio, it's got detailed instructions and screenshots with full sample code: Writing your first native module for node.js on Windows.

To use this module open cmd.exe and install the module:

npm install windows-eventlog  

Now create a simple script to write some test messages:

var EventLog = require('windows-eventlog').EventLog  
  , logger = new EventLog('dailyjs-logs');

logger.log('Hello from DailyJS');  

This won't run yet, however. Start another cmd.exe, but this time right-click the icon and select "Run as administrator":

Run as administrator

Now the example above should run correctly. Open Event Viewer, then select "Windows Logs", "Application", and look for logs with the source dailyjs-logs (assuming you didn't change it). You should see something like this:

Event Viewer

If portability with existing Unix software is required, then check out José's transport for Winston that uses this module.


tutorials cli node logging unix

Unix and Node: Syslog

Posted on .

Syslog is a standardised logging system that's present in most BSD and Linux distributions. There are various implementations; syslog-ng is a popular one that I usually find myself using. The interesting thing about syslog is it can be configured to store messages anywhere -- logs can be written to files or remote daemons.

The main reason for using syslog in your Unix-oriented projects is to separate the concerns between your application code and configuration. The same application logging to a local syslog daemon could log to a remote daemon without any changes to the application itself. In addition, syslog also has lots of useful features like log rotation, file compression, and interoperability with other applications that use syslog.

It's amazing to think that syslog was originally created by Eric Allman as part of Sendmail. Over the years it's found uses far beyond its origins, and as a result there are now several standards that pertain to syslog


templating node logging modules podcasts documentation arduino

Node Roundup: 0.6.5, NodeUp, Logme, Consolidate.js, mdoc, Firmata, Nodeflakes

Posted on .

You can send your Node modules and articles in for review through our [contact form](/contact.html) or [@dailyjs](http://twitter.com/dailyjs).

Node 0.6.5

Node 0.6.5 is out, which upgrades V8 to and potentially avoids national
firewall-related issues.


NodeUp is a podcast all about Node. In NodeUp Nine features Isaac Z. Schlueter, Matt Ranney,
Dominic Tarr, and James Halliday discussing scaling, deployment, and
Erlang. Other topics include migrating to Node 0.6 and hosting on Joyent
with Solaris.

Subscribe with either iTunes or RSS:


Logme (License: MIT, npm: logme) by Veselin Todorov is a slick little logging library. Basic usage looks
like this:

var logme = require('logme');

It has a lot of colour themes, which are set by instantiating a
Logme object:

var Logme = require('logme').Logme;
  , logme = new Logme({ theme: 'smile' });

logme.error('This is now themed.');

The only thing I miss is the ability to quickly append values with
spaces, like this: console.log('Value:', value);.

It's worth remembering that console also comes with
console.error, which will write to stderr.


Consolidate.js (License: MIT, npm: consolidate) by TJ Holowaychuk is a wrapper that gives template engines the same API. TJ's documentation mentions that
Express 3.x uses the signature (path[, locals], callback)
for template rendering, which is the same as Consolidate.js.

This library adds a thin layer that makes it easier to switch between
different template engines.


mdoc (License: MIT, npm: mdoc) by Miller Medeiros is a markdown-based documentation generator. It'll create HTML files for each markdown file in a directory, and a
table of contents.

One of the author's examples is unofficial Node mdoc-generated
He's only been working on it for a few weeks, yet the style of the
documentation it generates is readable and suits larger projects.

Some projects benefit handcrafted documentation rather than JSDoc-style
API documentation. Miller wrote a post about this topic called Inline
Documentation: Why I'm Ditching


Firmata (GitHub: jgautier / firmata, License: MIT, npm:
firmata) by Julian Gautier is a library for interacting with Arduino boards running the firmata protocol.

If you're a Node developer you may find this more appealing than typical
Arduino code:

var firmata = require('firmata')
  , board;

board = new firmata.Board('path to usb', function() {
  // Arduino is ready to communicate


Nick Payne sent in
Nodeflakes (GitHub: makeusabrew / nodeflakes), a Twitter Streaming API experiment that displays CSS3 unicode snowflakes
that display tweets. The architecture is actually multiprocess, using a
producer/consumer architecture. The client-side code is in

Despite appearing to be a holiday-themed gimmick, Nodeflakes is very
educational. The author has written a detailed blog post about the
project: Nodeflakes - real time tweet powered


frameworks graphics audio logging

d3.js, log.io, Buzz

Posted on .


Data-Driven Documents (GitHub: mbostock / d3, License) by Michael Bostock is a library for manipulating HTML based on data. It can
be used to visualise data using HTML or SVG, and supports interactivity
and animations.

This relatively simple graph example demonstrates some
basic visualisation and animation possibilities. This choropleth
some of d3's features in a more concise manner, and this Voronoi
is just fun to
play with!

The author has written detailed documentation and tutorials for
. It also includes a guide for
people who have worked with
Protovis (also by Mike Bostock).


Log.io (GitHub: NarrativeScience / Log.io, License: Apache
) by Mike Smathers and Narrative Science is log viewer written with
Node. It can be used to monitor logs from multiple machines, generating
data effectively instantly using inotify then pushing them to the
browser with socket.io.

There's a live demo running on logio.org:8998.

Although the authors have a lot planned, the project is already
formidable. Best of all, it's fast:

Log.io has no persistence layer. Harvesters are informed of file changes via inotify, and log messages hop from harvester to server to web client via socket.io. The result is fast; internal benchmarks have exceeded 5000 messages/sec.


Buzz (GitHub: jaysalvat / buzz, License: MIT) by Jay Salvat
is a library that makes working with the audio element
easier. It has a chainable API:

var mySound = new buzz.sound( '/sounds/myfile', {
  formats: [ 'ogg', 'mp3', 'acc' ]

  .bind('timeupdate', function() {
    var timer = buzz.toTimer(this.getTime());
    document.getElementById('timer').innerHTML = timer;

Recently I've been working with HTML5 audio and it's not exactly as
straightforward as it should be. Buzz looks like it does some of the
things I found awkward -- for some reason most browsers seem to say
maybe for canPlayType('/audio/aac') which
confused me when I knew they wanted vorbis. Buzz makes this easier by
accepting groups of files for each supported format then testing to see
which the browser can play, using the right jiggery pokery behind the