debug-console v1.0.9
debug-console
The ddebug-console library exported as Node.js modules.
Docs
Creates a 'logs' folder at root and creates logs based on date/time at set debug points. As an option you can send to console instead of saving as a file. You can send variables at the debug points to dump into the log file.
This is great for slient debuging
Installation
npm install debug-console
Structure
To log an error with your description
var debugLogger = require('debug-console');
debugLogger('Error for Log'); // to save as a file
let options = {console: true};
debugLogger('Error for Log, options); // to display to console
if you wish to indicate a type of error
debugLogger('Sample Error for Log', 3); // to save as a file
let options = {console: true};
debugLogger('Sample Error for Log', 3, options); // to display to console
The debug number refers to the type or error notification you want to see Here are the different types - 7 (debug) is default if null
0:'EMERGENCY' 1:'ALERT' 2:'CRITICAL' 3:'ERROR', 4:'WARNING' 5:'NOTICE' 6:'INFO' 7:'DEBUG'
Passing variables for debug
If you want to dump variables at this point of the debug, add the vars Create and Object (key:value) to pass the vars for the scope
let s = 'sample var 1';
let t = 'sample var 2';
let vars = { s:s, t:t };
let options = {vars: vars};
debugLogger('Sample Error for Log', 2, options); // to save as a file
let options = {console: true, vars: vars};
debugLogger('Sample Error for Log', 2, options); // to display to console
sample log
ALERT (action must be taken immediately): "Error for Log"
METHOD "router.get" LINE: 326 FILE: "app.js"
----------------------------------------------------------------------
ERROR (error condition): "Sample Error for Log"
METHOD "router.get" LINE: 328 FILE: "app.js"
VARS
s = sample var 1
t = sample var 2
----------------------------------------------------------------------
WARNING (warning condition): "Error for Log"
METHOD "router.get" LINE: 329 FILE: "app.js"
----------------------------------------------------------------------
Support
Tested in Chrome 53-54, Firefox 48-49, IE 11, Edge 14, Safari 9-10, Node.js 6-7, & PhantomJS 2.1.1. Automated test runs are available.