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

gengojs-debug

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

gengojs-debug - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

config.json

86

lib/index.js

@@ -0,3 +1,7 @@

'use strict';
import debug from 'debug';
import { install as map } from 'source-map-support';
import chalk from 'chalk';
import _ from 'lodash';
import 'source-map-support/register';
/**

@@ -7,25 +11,51 @@ * Debug is a debug wrapper for gengo.js

class Debug {
constructor (namespace, level, args) {
map();
this.namespace = namespace;
this.level = level;
this.args = args;
this.debug = (()=>{
var obj = {};
var gengo = 'gengo';
var namespaces = ['core','parser', 'router',
'backend', 'api', 'localize', 'header'];
var levels = ['debug', 'warn', 'error', 'info', 'verbose', 'silly'];
namespaces.forEach(function(namespace) {
levels.forEach(function(level) {
var key = gengo + '.' + namespace + ':' + level;
obj[key] = debug(gengo + '.' + namespace + ':' + level);
}, this);
}, this);
return obj;
})();
}
log () {
this.debug['gengo' + '.' + this.namespace.toLowerCase() + ':' +
this.level.toLowerCase()].apply(null, this.args);
constructor(namespace) {
// Set the namespace
this.namespace = namespace;
// Set the levels
var levels = ['debug', 'warn', 'error', 'info', 'verbose', 'silly'];
// Set up our personal console which
// will be build the log functions by type
this.console = (() => {
var obj = {};
var gengo = 'gengo';
var namespaces = ['core', 'parser', 'router',
'backend', 'api', 'localize', 'header'
];
// Build it!
namespaces.forEach(function(namespace) {
levels.forEach(function(level) {
var key = gengo + '.' + namespace + ':' + level;
obj[key] = debug(gengo + '.' + namespace + ':' + level);
}, this);
}, this);
return obj;
})();
// Apply color to the arguments if necessary and output them!
levels.forEach(level => {
this[level] = (...args) => {
var namespace = 'gengo' + '.' + this.namespace.toLowerCase() + ':' + level;
args = args.map(a => {
var temp;
try {
if (!_.isFunction(a) || !_.isString(a))
temp = JSON.stringify(a, null, 2);
} catch (error) {}
return temp || a;
});
if (level === 'error') args = args.map(a => {
return chalk.red(a);
});
if (level === 'warn') args = args.map(a => {
return chalk.yellow(a);
});
if (level === 'info') args = args.map(a => {
return chalk.green(a);
});
this.console[namespace].apply(null, args);
return this;
};
});
}

@@ -37,9 +67,7 @@ }

* @param {string} namespace - The namespace of the gengo to debug.
* @param {string} level - The level of debug to output.
* @param {*} args - The arguments to output.
* @example
* debugify('core.plugins', 'warn', 'Hello world')
* debugify('core.plugins').warn('hello')
*/
export default (namespace, level, ...args) => {
(new Debug(namespace, level, args)).log();
export default (namespace) => {
return new Debug(namespace);
};
{
"name": "gengojs-debug",
"version": "1.1.1",
"version": "2.0.0",
"description": "The debugger console for gengo.js",
"main": "index.js",
"main": "src/index.js",
"scripts": {

@@ -26,7 +26,20 @@ "test": "echo \"Error: no test specified\" && exit 1"

"homepage": "https://github.com/iwatakeshi/gengojs-debug#readme",
"devDependencies": {},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-babel": "^5.2.1",
"gulp-changelog": "^1.0.0",
"gulp-gh-pages": "^0.5.2",
"gulp-jsbeautify": "^0.1.1",
"gulp-jshint": "^1.11.2",
"gulp-shell": "^0.4.3",
"gulp-sourcemaps": "^1.6.0",
"jshint-stylish": "^2.0.1",
"rimraf": "^2.4.3"
},
"dependencies": {
"chalk": "^1.1.1",
"debug": "^2.2.0",
"lodash": "^3.10.1",
"source-map-support": "^0.3.2"
}
}
# gengojs-debug
The debugger console for [gengo.js](http://github.com/iwatakeshi/gengojs)
The debugger console for [gengo.js](http://github.com/gengojs/gengojs)

@@ -10,3 +10,3 @@ ## Usage

debug(namespace:string, level:string, args:*);
debug(namespace:string).[level](args:*);
```

@@ -17,5 +17,15 @@ #### ES5

debug(namespace:string, level:string, args:*);
debug(namespace:string).[level](args:*);
```
It's even possible to chain the methods:
```javascript
/* Example */
debug('core')
.warn('This is a warning')
.error('This is an error!');
```
In terminal:

@@ -63,2 +73,2 @@

DEBUG=gengo.parser:debug gengo.router:*
```
```

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