Logdown: Generate Logs with Markdown

2015-03-17 00:00:00 +0000 by Alex R. Young

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+.