rf-log
Simple and Ready logging lib - no dependencys.
npm install rf-log
Example 1
let log = start"[SYSTEM-XY]"; log;log;log;log;log;
Example 2
var log = ; log;logwithTime;logoptionsmainPrefix = '[SYSTEM-XY]';log;
Second prefix for libs
This helps to find the origin of a message faster
// NOTE: we assume this is a lib, and rf-log was already started in another file with the mainPrefix '[yourProcess]' // start the logger and tell it the name of your libvar log = prefix'[DB-module]' // no need mention `DB Module` againlogloglog
Log to a file
var log = ; logoptionslogFilePath = __dirname + "/log.txt";log;
Options
var options = options;// the object is in every `require(rf-log)` present and looks like: mainPrefix: '' time: false timeLocale: 'en-US' timeOptions: year: 'numeric' month: 'short' day: 'numeric' hour: 'numeric' minute: 'numeric' second: 'numeric' logFilePath: '' carriageReturn: true
Docs of time options
The lib uses Date.toLocaleString to create a time log. https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date
Docs of color options
http://stackoverflow.com/questions/9781218/how-to-change-node-jss-console-font-color
How the lib works - creation of the strings
Each string is built in the following pattern:
prefix + mainPrefix + secondPrefix + time + argumentsToLog
Development and Testing
npm install
To be able to run grunt-eslint. Run a test script and eslint
with:
npm test
Legal Issues
- Licenese: MIT
- Author: Felix Furtmayr