npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

debugger-256

v1.6.37

Published

A debugging utility based on 'debug' package that supports extended options and 256 colors

Downloads

24

Readme

debugger-256 Build Status NPM versionCoverage Status

Dependency Status devDependeny Status

A debugging tool utilizing prettyjson-256 that decorates logging output to the console. Reads settings from a user-defined configuration file to control verbosity of different modules (called subsystems). This configuration file is watched for changes so the server does not have to be reloaded for filtering and formatting settings to be applied.

Installation

$ npm install --save debugger-256

Usage

This module returns a function that is passed an optional subsystem name similar to the debug module. It returns 7 logging functions of different levels:

Name | Level --- | --- fatal | 0 error | 1 warn | 2 log | 3 info | 4 debug | 5 trace | 6

Each will output as different color, and optionally be filtered by a configuration file. The basic idea is to differentiate your logging messages into these different levels, which when combined with filtering allows one to quickly see very detailed output for some subystems without being cluttered by messages from other subsystems.

var debug = require('debugger-256')('app');
debug.log("hello world");

//or
var logWarn = require('debugger-256')('app').warn;
logWarn("hello world");

// or
var createDebug = require('debugger-256');
createDebug('app:subsystem1').log('hello world');
createDebug('app:subsystem2').error('this is an error');

ES6 usage

const { info, warn } = require('debugger-256')('app:subsystem1');
info('destructing assignmnet is cool');
warn('all of these should appear under app:subsystem1');

Inline string coloring

THe customColors property can be assigned tags with colors during initialization to colorize parts of single line strings.

var debug = require('debugger-256')('app');
debug.init({
  customColors: {
    resCode: { fg: [3,3,1] },
    resTime: { fg: [1,2,3] }
   }
});
// wrap each string section to be colorized in parenthesis,
// followed by a list of the customColor tags assigned to the key 'color'
debug.log("The response code returned was %200 - Received% in %50ms%",
  { color: 'resCode' }, { color: 'resTime' });

Example Output 64

Conventions

Based on the debug package modular approach, debugger-256 expects to be initialized with the name of the module or 'subsystem'. Subsystems should be nested with colons, i.e. 'api:db:user' would indicate the current 'user' module is part of a parent 'db' module which is part of the root subsystem 'api'. This allows for easy filtering and formatting through the options.

Options

All options of prettyjson-256 can be passed to the 'init' function, or they can be added to the configuration file described in the next section.

var debug = require('debugger-256')('app');
var initOptions = {
  depth: 3,
  alphabetizeKeys: true,
  colors: {
    keys: { fg: [0,3,2] },
    boolTrue: { bg: [0,2,0] }
  }
};
debug.init(initOptions);
debug.log(initOptions);

Example Output 4

Configuration file

A configuration file named '.debugger-256' can be put in the root directory of the project to provide global options and filtering. This file is watched and changes will take effect without requiring a restart of the process. The file should be JSON format:

.debugger-256

 {
   "app" : {
     "*" : 2,
     "response" : 6,
     "request" : 6
   }
 }

This specifies that messages from 'app:response' and 'app:request' level 6 and lower (all messages) wouldbe output, the '*':3 specifies that app subsystems that aren't specified should only ouput messages from level and lower (only fatal, error, and warn).

You can also specify debugger-256 custom options (same as you would pass as an argument) by adding them to key '_debugger-256':

.debugger-256

 {
   "app" : {
     "*" : 2
   },
   "_debugger-256" : {
      "depth" : 3,
      "customColors" : {
        "responseGet": { "fg": [1, 4, 3] },
        "requestGet": { "fg": [1, 4, 3] },
      }
   }
 }

For example: Example Output 2

The dark blue lines are from 'log' calls (level 3), the light blue lines with header information are from trace calls (level 6). If we just wanted to show the log lines, change the numbers of the relevant subsystems to the maximum level you want to show (in this case log or level 3).

 {
   "app" : {
     "*" : 2,
     "response" : 3,
     "request" : 3
   }
 }

Save the file and the filtering will be applied automatically without a server restart.

Example Output 3

Other Examples

Running Tests

To run the test suite first invoke the following command within the repo, installing the development dependencies:

$ npm install

then run the tests:

$ npm test