Giter Site home page Giter Site logo

debug-util's Introduction

Debug Utility Tool

This is a very easy to use tool that intends to help making logging and console.logging rich. This tool will allow you to have detailed message of what is going on with your project while debugging.

As developers we are constantly console.logging here and there to check what is returned, what is contained in a variable or to simply add tracks to know how the code is executing.

This tool allow you to set a message and everything else is done for you. The tool will give you the line and file the error happened at, who called, what method was used and if any data was returned and display it nicely.

The tool also comes with sub-functionality that will allow you to just log to a file or just console log it nicely.

console

Installation

download this repo to your local environment and through terminal navigate to the download folder destination and run this following command to install it:

npm install

Usage

You can simply require it to a variable and start using it.

require

Turn Debug Mode ON

This module blocks any console log among your code so to use this module you must first turn DEBUG mode ON:

Lets say you want to run server.js on debug mode

node server.js --debug true

or

node server.js -d true

Both ways you can set DEBUG on

.debug

The .debug funtion allows for 3 optional parameters and 1 required.

You must provide a message to it

util.debug('This message is required');

Specify a Message Type

util.debug('This message is required', 1);

You can pass it a 0, 1, or 2 and it cannot be a string;

  • 0 = Error;
  • 1 = Warn;
  • 2 = Info;

By default and message is set to be a Mesg

defaultMsg

Pass some DATA

if you simply want to check what data is returned or being processed you can simply pass it as the 3 argument. This means that at this point you must specify a message type.

for example:

let n = 4;

function foo(number){
    util.debug('what is the number?', 2, number)
}

foo(n);

// --- outputs
/*- Debugging -----------------
    Time: 0:15 20
    Info: what is the number?
    Line: 7
    File: /Users/ecorreia/Sites/_tests/debugTool/node_modules/caller-id/lib/caller-id.js
    Func: getData | type: Object | method: getData
    Data: number 4
*/

Callback function

util.debug('what is the number?', 2, number, function (err) {
    if(err == 0){
      // do something
    }else{
      // do another
    }
  })

This callback function is used to see if the tool did its job or failed. You will double check if the tool threw an error and you didnt happen to catch it.

debug-util's People

Contributors

ecorreia45 avatar

Watchers

Kevin Smith avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.