mirror of
https://github.com/mathew-kurian/Scribe.js
synced 2025-04-26 07:14:58 +00:00
Add colors
This commit is contained in:
parent
bc2ceb7b91
commit
dc80fc955a
2 changed files with 16 additions and 7 deletions
|
@ -5,8 +5,8 @@
|
||||||
var stack = require('callsite'),
|
var stack = require('callsite'),
|
||||||
util = require('util'),
|
util = require('util'),
|
||||||
EventEmitter = require('events').EventEmitter,
|
EventEmitter = require('events').EventEmitter,
|
||||||
path = require('path');
|
path = require('path'),
|
||||||
// colors = require('colors');
|
colors = require('colors/safe');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* consoleOriginal
|
* consoleOriginal
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
* @param {int} opt.contextMediumSize Medium size of the context part of a log message.
|
* @param {int} opt.contextMediumSize Medium size of the context part of a log message.
|
||||||
* Used when calculating indent. Default to 45.
|
* Used when calculating indent. Default to 45.
|
||||||
* @param {int} opt.spaceSize Space between context part and log part. Default to 4.
|
* @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.alwaysTags Always print tags (even without tag() ). Default false.
|
||||||
* @param {Boolean} opt.alwaysLocation Always print location (even without file() ). Default false.
|
* @param {Boolean} opt.alwaysLocation Always print location (even without file() ). Default false.
|
||||||
|
@ -113,7 +113,7 @@
|
||||||
contextMediumSize : opt.contextMediumSize || 45,
|
contextMediumSize : opt.contextMediumSize || 45,
|
||||||
spaceSize : opt.spaceSize || 4,
|
spaceSize : opt.spaceSize || 4,
|
||||||
|
|
||||||
color : opt.color || "blue",
|
color : opt.color || "cyan",
|
||||||
|
|
||||||
alwaysTags : opt.alwaysTags || false,
|
alwaysTags : opt.alwaysTags || false,
|
||||||
alwaysLocation : opt.alwaysLocation || false,
|
alwaysLocation : opt.alwaysLocation || false,
|
||||||
|
@ -297,7 +297,7 @@
|
||||||
* You can then use it with console.myNewLogger
|
* You can then use it with console.myNewLogger
|
||||||
*
|
*
|
||||||
* @param {String} name The name of the logger.
|
* @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
|
* See text colors from https://github.com/Marak/colors.js
|
||||||
*
|
*
|
||||||
* @param {Object} opt Optional options object. @see Console2 opt for default values.
|
* @param {Object} opt Optional options object. @see Console2 opt for default values.
|
||||||
|
@ -363,7 +363,16 @@
|
||||||
//If the logger should print the message
|
//If the logger should print the message
|
||||||
//Print it
|
//Print it
|
||||||
if (opt.logInConsole) {
|
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();
|
this._reset();
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"callsite": "^1.0.0",
|
"callsite": "^1.0.0",
|
||||||
"colors": "^0.6.2",
|
"colors": "^1.0.0",
|
||||||
"express": "^4.7.2",
|
"express": "^4.7.2",
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^0.4.5",
|
||||||
"grunt-contrib-jshint": "^0.10.0",
|
"grunt-contrib-jshint": "^0.10.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue