Yet Another Node.js Logger: femto-logger

femto.png

Ok, so I don’t know if we really need another logging framework, but after looking at various ones available in the registry, I found that I was implementing my own repeatedly, so I figured I would just stick it out there.

I had the goals of a logging framework that:

The NPM package is here and Git project here.

Usage, as I mentioned, is dead simple:

var logging = require('femto-logger');

logging.info('Something happened.');

But, it can still be pretty well customized…

// Turn coloring on or off...
logging.config.coloring = true | false;

// Set debug color to bright cyan...
logging.config.colors.debug = logging.BRIGHT_CYAN;

// Set label for fatal log lines from FATAL to RED ALERT...
logging.config.labels.fatal = 'RED ALERT';

// Set format of timestamp (follows moment formatting)...
logging.date.format = logging.ISO8601 | 'HH:mm:ss.SSS';

I just added printf-style message formatting as well, so something like this will work:

logging.debug('This will work now (%s, %d)', 'abc', 789);

I hope someone finds this useful!

 
5
Kudos
 
5
Kudos

Now read this

Manage processes with nproc

So, after 30 years of “heavier” languages such as C++, Java, C#, I’m really liking Node.js as a change. Being able to prototype things quickly, having the server start up in sub-second times, and not being encased in a few hundred... Continue →