Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-debug-tool

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-debug-tool - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.idea/node-debug-tool.iml

2

examples/example.js

@@ -17,1 +17,3 @@ 'use strict';

}, 2000);
worker1.log(new Error('abc'));

21

lib/node-debug-tool.js

@@ -43,3 +43,2 @@ /**

var generateOutput = function (string, prefix, color) {
if (process.env.DEBUG_MODE != true) {

@@ -49,9 +48,21 @@ return;

var date = new Date(),
time = ! isTTY ? ('(' + date.toUTCString() + ')') + ' ' : '',
prefixColor = isTTY ? '\u001b[3' + color + 'm' : '',
resetColor = isTTY ? '\u001b[0m' : '';
var time = '',
prefixColor = '',
resetColor = '',
date = new Date();
// using color on TTY, otherwise using UTCString prefix
if (isTTY) {
prefixColor = '\u001b[3' + color + 'm';
resetColor = '\u001b[0m';
} else {
time = '(' + date.toUTCString() + ')' + ' ';
}
tickTimer();
if ( ! string instanceof Error) {
string = JSON.stringify(string, null, 4);
}
console.log(

@@ -58,0 +69,0 @@ time + '['+workerName+'] ' +

{
"name": "node-debug-tool",
"version": "0.1.0",
"version": "0.1.1",
"description": "Node debug tool",

@@ -5,0 +5,0 @@ "main": "./lib/node-debug-tool.js",

# Node Debug Tool
[![Build Status](https://travis-ci.org/danrevah/node-debug-tool.svg?branch=master)](https://travis-ci.org/danrevah/node-debug-tool)
> Tiny node.js debugging tool with colors and timing functionality
## Table of contents
* [Installation](#installation)
* [Usage](#usage)
## Installation
```
$ npm install node-debug-tool
```
## Usage
The `DEBUG_MODE` environment variable, must be set to 1 in order to see the deubbing information.
*Code example:*
```javascript
var worker1 = require('../lib/node-debug-tool')('worker 1');
var worker2 = require('../lib/node-debug-tool')('worker 2');
worker1.error('Some Error');
worker1.warning('Some warning');
worker1.log('Some logging');
worker2.error('Foo');
worker2.warning('Bar');
worker2.log('Foo bar');
setInterval(function () {
worker2.log('Some Foo Bar Log');
}, 2000);
```
*Usage & Output:*
![alt tag](http://i57.tinypic.com/2ez3brl.jpg)

@@ -24,3 +24,3 @@ var chai = require('chai');

it("should return a colored red text string with [Error] prefix and time tick", function() {
expect(mockConsoleLogAndCallDebug('error', 'foo')).to.match(/\[Worker 1\] \u001b\[31m\[Error\] foo\u001b\[0m \+\d+ms/);
expect(mockConsoleLogAndCallDebug('error', 'foo')).to.match(/\[Worker 1\] \u001b\[31m\[Error\] "foo"\u001b\[0m \+\d+ms/);
});

@@ -31,3 +31,3 @@ });

it("should return a colored yellow text string with [Warning] prefix and time tick", function() {
expect(mockConsoleLogAndCallDebug('warning', 'foo')).to.match(/\[Worker 1\] \u001b\[33m\[Warning\] foo\u001b\[0m \+\d+ms/);
expect(mockConsoleLogAndCallDebug('warning', 'foo')).to.match(/\[Worker 1\] \u001b\[33m\[Warning\] "foo"\u001b\[0m \+\d+ms/);
});

@@ -38,5 +38,5 @@ });

it("should return a colored green text string with [Debug] prefix and time tick", function() {
expect(mockConsoleLogAndCallDebug('log', 'foo')).to.match(/\[Worker 1\] \u001b\[32m\[Debug\] foo\u001b\[0m \+\d+ms/);
expect(mockConsoleLogAndCallDebug('log', 'foo')).to.match(/\[Worker 1\] \u001b\[32m\[Debug\] "foo"\u001b\[0m \+\d+ms/);
});
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc