1. debug-fabulous
visionmedia debug extensions rolled into one
debug-fabulous
Package: debug-fabulous
Created by: nmccready
Last modified: Tue, 14 Jun 2022 22:06:47 GMT
Version: 2.0.2
License: MIT
Downloads: 1,810,565
Repository: https://github.com/nmccready/debug-fabulous

Install

npm install debug-fabulous
yarn add debug-fabulous

debug-fabulous NPM version build status Test coverage

Install

npm install --save debug-fabulous

Purpose:

Wrapper / Extension around visionmedia's debug to allow lazy evaluation of debugging via closure handling.

Why would I consider using this library?

The main utilities added to this library is lazy log level evaluation. This allows whatever logged strings to only be created and evaluated if a log level is active. This can considerably reduce the amount of memory used in logging when you are not using.

With this in mind, there are no excuses to not log anything and everything as performance can be kept in check easily (via log levels).

Proof

For analysis of the performance results are in perfWith.out and perfWithout.out.

In summary, the tests using this library are using 3 times less memory for the same logging statements (when the log levels are disabled).

This library essentially wraps two things:

  • lazy-eval: debug closure handling
  • spawn: spawns off existing namespaces for a sub namespace.

Example:

For usage see the tests or the example below.

 var debug = require('')();
// force namespace to be enabled otherwise it assumes process.env.DEBUG is setup
// debug.save('namespace');
// debug.enable(debug.load())
debug = debug('namespace'); // debugger in the namespace
debug(function() {
  return 'something to log' + someLargeHarryString;
});
debug(() => 'something to log ${someLargeHarryString}');
debug('small out'); // prints namespace small out
var childDbg = debug.spawn('child'); // debugger in the namespace:child
childDbg('small out'); // prints namespace:child small out
var grandChildDbg = debug.spawn('grandChild'); // debugger in the namespace:child:grandChild
grandChildDbg('small out'); // prints namespace:child:grandChild small out

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code