DailyJS

Logdown: Generate Logs with Markdown

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

libraries console logging modules

Logdown: Generate Logs with Markdown

Posted by Alex R. Young on .
Featured

libraries console logging modules

Logdown: Generate Logs with Markdown

Posted by Alex R. Young 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+.