Permalink
Browse files

Make logging respect --quiet

  • Loading branch information...
1 parent 8e034fd commit 8603f758a7662b9b5e317066cc774350618befb9 @davglass davglass committed Sep 27, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/log.js
View
@@ -6,13 +6,17 @@ http://yuilibrary.com/license/
var color = require('ansi-color').set;
var hasColor = false;
var stdio;
+var quiet;
try {
stdio = require("stdio");
hasColor = stdio.isStderrATTY();
} catch (ex) {
hasColor = true;
}
+exports.quiet = function () {
+ quiet = true;
+};
exports.color = function (str, code) {
if (!hasColor) {
@@ -27,11 +31,15 @@ exports.color = function (str, code) {
var prefix = exports.color('shifter', 'magenta');
exports.info = function (str) {
- console.log(prefix, color('[info]', 'white'), str);
+ if (!quiet) {
+ console.log(prefix, color('[info]', 'white'), str);
+ }
};
exports.log = function (str) {
- console.log(prefix, color('[queu]', 'cyan'), str);
+ if (!quiet) {
+ console.log(prefix, color('[queu]', 'cyan'), str);
+ }
};
exports.warn = function (str) {

0 comments on commit 8603f75

Please sign in to comment.