Skip to content

Commit

Permalink
automatic color removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Jun 21, 2016
1 parent 7654543 commit d3e0fd9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,25 @@ function print(event, text, isExtraLine) {
t = new Date();
s = cct.time(formatTime(t)) + ' ' + text;
}
var display = true, log = module.exports.log;
var noColors, display = true, log = module.exports.log;
if (log instanceof Function) {
// the client expects log notifications;
var info = {
event: event,
time: t,
text: removeColors(text).trim()
};
log(removeColors(s), info);
s = removeColors(s);
noColors = true;
log(s, info);
display = info.display === undefined || !!info.display;
}
// istanbul ignore next: cannot test the next
// block without writing things into the console;
if (display) {
if (!process.stdout.isTTY && !noColors) {
s = removeColors(s);
}
console.log(s);
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pg-monitor",
"version": "0.5.9",
"version": "0.5.10",
"description": "Event monitor for pg-promise.",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit d3e0fd9

Please sign in to comment.