A highly configurable & lightweight debug library that prints debug messages beautifully. It works in Node.js and Web browser environments with very low memory footprint.
Members
-
static color :Object.<string>
-
Different ANSI color to decorate different segments
Properties:
Name Type Description resetstring Text Color Reset
blackstring Text Color Block
redstring Text Color Red
greenstring Text Color Green
yellowstring Text Color Yellow
bluestring Text Color Blue
magentastring Text Color Magenta
cyanstring Text Color Cyan
whitestring Text Color Cyan
bgBlackstring Background Color Black
bgRedstring Background Color Red
bgGreenstring Background Color Green
bgYellowstring Background Color Yellow
bgBluestring Background Color Blue
bgMagentastring Background Color Magenta
bgCyanstring Background Color Cyan
bgWhitestring Background Color White
Methods
-
static alert(…var_args)
-
Prints alert messages in level 4
Parameters:
Name Type Attributes Description var_args* <repeatable>
Variadic Argument
Examples
debug.alert("An alert message!");const birthTimestamp = { date : "15/12/1993", time : "12:05 AM" }; debug.alert(birthTimestamp); -
static attachStream(stream)
-
Attaches stream to pipe debug output
Parameters:
Name Type Description streamObject.<stream> Stream to attach
-
static critical(…var_args)
-
Prints critical messages in level 1
Parameters:
Name Type Attributes Description var_args* <repeatable>
Variadic Argument
Examples
debug.critical("API server critical error");const criticalMessage = { message : "Some Critical Error" }; debug.critical(criticalMessage); -
static detachStream(stream)
-
Detaches stream from debug output
Parameters:
Name Type Description streamObject.<stream> Stream to detach
-
static error(…var_args)
-
Prints error messages in level 2
Parameters:
Name Type Attributes Description var_args* <repeatable>
Variadic Argument
Examples
debug.error("Error in recording server");const errorMessage = { message : "Some Error", errorCode : 4 }; debug.error(errorMessage); -
static generatePolicy(lowerLimit, upperLimit) → {Object.<policy>}
-
Generates policy for different memory monitors
Parameters:
Name Type Description lowerLimitnumber Lower limit
upperLimitnumber Upper limit
Returns:
Object.<policy> -
static info(…var_args)
-
Prints info messages in level 5
Parameters:
Name Type Attributes Description var_args* <repeatable>
Variadic Argument
Examples
debug.info("Here is an info message.");const birthTimestamp = { date : "15/12/1993", time : "12:05 AM" }; debug.info(birthTimestamp); -
static log(…var_args)
-
Prints log messages in level 6
Parameters:
Name Type Attributes Description var_args* <repeatable>
Variadic Argument
Examples
debug.log("Just a simple log message");const policy = { upperLimit : 70, lowerLimit : 20 }; debug.log(policy); -
static memoryWatermark()
-
Prints highest RAM usage in application. Scheduled healthcheck is needed to set watermark.
Example
memoryWatermark(); -
static nodeMemoryMonitor(stream, callback)
-
Prints RAM usage by Node.js
Parameters:
Name Type Description streamObject.<stream> Stream Object
callbackfunction Callback function to invoke when alarm triggers
Example
debug.nodeMemoryMonitor({ heapTotal: { upperLimit : 100 } }, function(){ debug.critical('Memory Usage Alarm : Total heap usage is above 100 MB'); } ); -
static scheduleHealthCheck(inputFunc, timeInMinutes)
-
Set Schedule to perform healthcheck
Parameters:
Name Type Description inputFuncfunction Healthcheck function
timeInMinutesnumbers Interval in minutes
Example
debug.scheduleHealthCheck(function(){ debug.memoryWatermark(); debug.sysMemoryMonitor(); debug.nodeMemoryMonitor({ heapTotal: { upperLimit : 5 } }, function(){ debug.critical('Memory Usage Alarm : Total heap usage is above 5 MB'); }); }, 10); -
static setOptions(userOptions)
-
Overwrites default options and debug text formats
Parameters:
Name Type Description userOptionsObject.<userOptions> Options User specific options
-
static sysMemoryMonitor(alarmPolicy, callback)
-
Prints RAM usage by operating system
Parameters:
Name Type Description alarmPolicyObject.<alarmPolicy> Policy object to trigger alarm
callbackfunction Callback function to invoke when alarm triggers
Example
debug.sysMemoryMonitor({ MemTotal: { upperLimit : 700 } }, function(){ debug.critical('Memory Usage Alarm : Total system memory usage is above 700 MB'); } ); -
static warn(…var_args)
-
Prints warn messages in level 3
Parameters:
Name Type Attributes Description var_args* <repeatable>
Variadic Argument
Examples
debug.warn("This is your last warning.");const resource = { RAM : 10, CPU : 60 }; debug.warn(resource);