Yet Another Node.js Logger: femto-logger
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:
- is dead simple to configure and use, with the configure part being optional
- provides colorizing of different log levels
- provides UTC-based timestamping with an ISO 8601 format for easy parsing
- can be customized if desired
- can use printf-style formatting for messages
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!