better debug output

This commit is contained in:
Philipp Kunz 2015-11-16 01:50:28 +01:00
parent d9679f79e2
commit c31265d4bd
5 changed files with 18 additions and 10 deletions

View File

@ -1,15 +1,15 @@
/// <reference path="typings/tsd.d.ts" /> /// <reference path="typings/tsd.d.ts" />
var beautylog = require("beautylog"); var beautylog = require("beautylog")("os");
var colors = require("colors"); var colors = require("colors");
var debugActive = false; var debugActive = false;
var smartdebug = { var smartDebug = {
log: function (message) { log: function (message) {
if (debugActive) { if (debugActive) {
beautylog.log("Debug:".zebra + ' ' + message); beautylog.log("###DEBUG:###".rainbow + ' ' + message);
} }
}, },
activate: function (debugArg) { activate: function (debugArg) {
debugActive = debugArg; debugActive = debugArg;
} }
}; };
module.exports = smartdebug; module.exports = smartDebug;

View File

@ -4,7 +4,7 @@
"description": "debug your JavaScript the smart way", "description": "debug your JavaScript the smart way",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "(cd ts/compile && node compile.js)", "test": "(cd ts/compile && node compile.js) && (node test.js)",
"reinstall": "(rm -r node_modules && npm install)", "reinstall": "(rm -r node_modules && npm install)",
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)", "release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
"startdev": "(git checkout master && git pull origin master)" "startdev": "(git checkout master && git pull origin master)"

View File

@ -1 +1,4 @@
var smartDebug = require("./index.js");
smartDebug.log("test");
smartDebug.activate(true);
smartDebug.log("test2");

View File

@ -1,12 +1,12 @@
/// <reference path="typings/tsd.d.ts" /> /// <reference path="typings/tsd.d.ts" />
var beautylog = require("beautylog"); var beautylog = require("beautylog")("os");
var colors = require("colors"); var colors = require("colors");
var debugActive:boolean = false; var debugActive:boolean = false;
var smartdebug = { var smartDebug = {
log: function(message:string){ log: function(message:string){
if (debugActive) { if (debugActive) {
beautylog.log("Debug:".zebra + ' ' + message); beautylog.log("###DEBUG:###".rainbow + ' ' + message);
} }
}, },
activate: function(debugArg:boolean){ activate: function(debugArg:boolean){
@ -14,4 +14,4 @@ var smartdebug = {
} }
}; };
module.exports = smartdebug; module.exports = smartDebug;

View File

@ -0,0 +1,5 @@
var smartDebug = require("./index.js");
smartDebug.log("test");
smartDebug.activate(true);
smartDebug.log("test2");