diff --git a/lib/console2.js b/lib/console2.js index 58521a4..f780930 100644 --- a/lib/console2.js +++ b/lib/console2.js @@ -5,8 +5,8 @@ var stack = require('callsite'), util = require('util'), EventEmitter = require('events').EventEmitter, - path = require('path'); -// colors = require('colors'); + path = require('path'), + colors = require('colors/safe'); /** * consoleOriginal @@ -87,7 +87,7 @@ * @param {int} opt.contextMediumSize Medium size of the context part of a log message. * Used when calculating indent. Default to 45. * @param {int} opt.spaceSize Space between context part and log part. Default to 4. - * @param {String} opt.color Default color output for all loggers. Default blue. + * @param {String} opt.color Default color output for all loggers. Default cyan. * * @param {Boolean} opt.alwaysTags Always print tags (even without tag() ). Default false. * @param {Boolean} opt.alwaysLocation Always print location (even without file() ). Default false. @@ -113,7 +113,7 @@ contextMediumSize : opt.contextMediumSize || 45, spaceSize : opt.spaceSize || 4, - color : opt.color || "blue", + color : opt.color || "cyan", alwaysTags : opt.alwaysTags || false, alwaysLocation : opt.alwaysLocation || false, @@ -297,7 +297,7 @@ * You can then use it with console.myNewLogger * * @param {String} name The name of the logger. - * @param {String} color Optional. Color of the console output. Default blue. + * @param {String} color Optional. Color of the console output. Default cyan. * See text colors from https://github.com/Marak/colors.js * * @param {Object} opt Optional options object. @see Console2 opt for default values. @@ -363,7 +363,16 @@ //If the logger should print the message //Print it if (opt.logInConsole) { - global.console.log(log.message); + + var msg; + + if (typeof colors[opt.color] === 'function') { + msg = colors[opt.color](log.message); + } else { + msg = log.message; + } + + global.console.log(msg); } this._reset(); diff --git a/package.json b/package.json index 8c8765f..1c52272 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "license": "MIT", "dependencies": { "callsite": "^1.0.0", - "colors": "^0.6.2", + "colors": "^1.0.0", "express": "^4.7.2", "grunt": "^0.4.5", "grunt-contrib-jshint": "^0.10.0",