This is yet another logger for nodejs. I departed from my previous experience with markdown friendly HTML tag names, along with the basic log functions I expect.
Using the Node.js stability index, this API is:
Stability: 2 - Unstable
npm install llogger
Once installed (and you're in the logger/ directory):
// Assuming you want only 1 logger in your file, just create it// (using the world's worst variable name).var l = require"llogger"create;// NOTE: llogger assumes all messages are text strings.// Standard logging methods with a bit of flavor added.l.log"normal log message";l.warn"normal warn message";l.error"normal error message";// And why not have HTML tag based methods?lh1"Section header.";lh2"Sub-section header.";lh3"Sub-sub-section header.";lh4"Sub-sub-sub-section header.";lh5"Sub-sub-sub-sub-section header.";lh6"Sub-sub-sub-sub-sub-section header.";lli"List item.";// Print an 80 character horizontal rule.lhr;// Increase the indentation level for this logger.lindent;lli"This is now indented one level.";l.log"log, warn, and error messages are immune to indentation.";// Decrease the indentation level for this logger.ldedent;lli"No longer indented.";// Turn on filename and linenumber display on this logger instance.ldisplayCallerInfotrue;l.log"This will now display the module name and line number from where it is called.";// Turn off filename and linenumber display on this logger instance.ldisplayCallerInfofalse;// Turn on filename and linenumber display globally across all loggers,// overriding the logger instance setting.require"llogger"globalDisplayCallerInfotrue;// Turn off filename and linenumber display globally across all loggers,// deferring to the logger instance setting.require"llogger"globalDisplayCallerInfofalse;
Rarely is software created in a vacuum, and that includes this lame logger. In addition to the modules referenced in the package.json file, I give credit to:
- Igor Urminček (nlogger at https://github.com/igo/nlogger) for how to get caller module name and line number.