Skip to content

Commit

Permalink
Allow disable log colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Elbandi committed May 8, 2014
1 parent c5ba95f commit d7db8a3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
1 change: 1 addition & 0 deletions config_example.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"logLevel": "debug",
"logColors": true,

"cliPort": 17117,

Expand Down
3 changes: 2 additions & 1 deletion init.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ var poolConfigs;


var logger = new PoolLogger({
logLevel: portalConfig.logLevel
logLevel: portalConfig.logLevel,
logColors: portalConfig.logColors
});


Expand Down
27 changes: 20 additions & 7 deletions libs/logUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var PoolLogger = function (configuration) {


var logLevelInt = severityValues[configuration.logLevel];
var logColors = configuration.logColors;



Expand All @@ -45,16 +46,28 @@ var PoolLogger = function (configuration) {
}

var entryDesc = dateFormat(new Date(), 'yyyy-mm-dd HH:MM:ss') + ' [' + system + ']\t';
entryDesc = severityToColor(severity, entryDesc);
if (logColors) {
entryDesc = severityToColor(severity, entryDesc);

var logString =
entryDesc +
('[' + component + '] ').italic;
var logString =
entryDesc +
('[' + component + '] ').italic;

if (subcat)
logString += ('(' + subcat + ') ').bold.grey
if (subcat)
logString += ('(' + subcat + ') ').bold.grey;

logString += text.grey;
logString += text.grey;
}
else {
var logString =
entryDesc +
'[' + component + '] ';

if (subcat)
logString += '(' + subcat + ') ';

logString += text;
}

console.log(logString);

Expand Down

0 comments on commit d7db8a3

Please sign in to comment.