Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Custom request logger for node.js
CoffeeScript JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

yalog... Yet Another Logger

yalog is a Node.js logging library that can

  • print log messages according to your own functions
  • be customized per module and per logging level
  • have any amount of logging levels
  • print statements in full color (background too!!!)
  • print statements with console qualities such as "italics" or "bold"
  • print messages with module name and current line number so you know from where it was called
  • be configured from file or by a module


npm install yalog


Add to your code:

var log = require('yalog').with(module);

module is object defined automatically by Node.js. This allows you to copy and paste the line into each file and leverage your filename. The file name matching is done with or the filename with the working directory and trailing '.js' removed. If you don't want automatic module names, replace it with your desired string name.

var log = require('yalog').with("myCustomName");

Arguments are not inspected unless the log level allows for printing of the statement. This avoids unnecessary object serialization calls before submitting your log statements., arg2, arg3);

Simple Example

var log = require('yalog').with(module);
log.test( "Test"  , 0);
log.trace("Trace" , 1);
log.debug("Debug" , 2); "Info"  , 3);
log.warn( "Warn"  , 4);
log.error("Error" , 5);'Array =', [1, 2, 3, 4], '; Object = ', {one: 1, two: 2});

// 2012-02-16T03:32:29.083Z TRACE main:23 - Trace 1
// 2012-02-16T03:32:29.085Z DEBUG main:24 - Debug 2
// 2012-02-16T03:32:29.085Z INFO  main:25 - Info 3
// 2012-02-16T03:32:29.085Z WARN  main:26 - Warn 4
// 2012-02-16T03:32:29.086Z ERROR main:27 - Error 5
// 2012-02-16T03:32:29.086Z INFO  main:28 - Array = [ 1, 2, 3, 4 ] ; Object =  { one: 1, two: 2 }

Advanced Example

Take a look at the examples directory for different examples.

// Load yalog configuration from another location to keep configurations in one spot.
var maxHelper = require('./examples/max_utilization_helper')
var log = maxHelper.with(module);

var answerObj = {is: 42};
answerObj.and = answerObj;

var ctxObj = {email: "", circularObj: answerObj, other: "contextInfo", fn: function(){return true;}};
maxHelper.add_context_flag(ctxObj); ctxObj, "The answer to life the universe and everything: '", answerObj, "'") ctxObj, "Info counter should be at 2. Counter value:")
log.debug(ctxObj, "Debug counter should be at 1. Counter value:")
log.trace(ctxObj, "this should not execute. Level is not included (too low in stack)") ctxObj, "Current 'ctxObj' obj: ", ctxObj)

// 2012-02-16T03:29:12.141Z;; INFO ; main:12; -; The answer to life the universe and everything: ' | { is: 42, and: [Circular] } | '; 1
// 2012-02-16T03:29:12.145Z;; INFO ; main:13; -; Info counter should be at 2. Counter value:; 2
// 2012-02-16T03:29:12.145Z;; DEBUG; main:14; -; Debug counter should be at 1. Counter value:; 1
// 2012-02-16T03:29:12.145Z;; INFO ; main:16; -; Current 'ctxObj' obj:  | { email: '', circularObj: { is: 42, and: [Circular] }, other: 'contextInfo', fn: [Function], _myContextFlag: true }; 3


Dev Development

make compile  # compile files
make watch    # constantly watch files


Released under MIT License. Enjoy and Fork!

Something went wrong with that request. Please try again.