Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Properly write error/failure log to stderr (on top of devel) #512

Closed
wants to merge 1 commit into from

3 participants

@rxaviers

New PR based on #511, but now on top of devel branch

@rxaviers rxaviers Properly write error/failure log to stderr
* log.ok -> stdin
* log.error -> stderr*
* log.success -> stdin
* log.fail -> stderr*
5e26251
@rxaviers

Any chance this go into 0.4? It's a pretty simple change.

@cowboy cowboy closed this
@shama
Owner

devel is now master. Could you reopen this pull request against the master branch now? Thanks!

@rxaviers

opened PR #570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 6, 2012
  1. @rxaviers

    Properly write error/failure log to stderr

    rxaviers authored
    * log.ok -> stdin
    * log.error -> stderr*
    * log.success -> stdin
    * log.fail -> stderr*
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/grunt/log.js
View
15 lib/grunt/log.js
@@ -37,20 +37,21 @@ function markup(str) {
}
// Write output.
-log.write = function(msg) {
+log.write = function(msg, stream) {
// Actually write output.
if (!log.muted && !suppressOutput) {
hasLogged = true;
- process.stdout.write(markup(msg));
+ stream = stream || process.stdout;
+ stream.write(markup(msg));
}
// Chainable!
return this;
};
// Write a line of output.
-log.writeln = function(msg) {
+log.writeln = function(msg, stream) {
// Actually write output.
- this.write((msg || '') + '\n');
+ this.write((msg || '') + '\n', stream);
// Chainable!
return this;
};
@@ -60,9 +61,9 @@ log.writeln = function(msg) {
log.error = function(msg) {
if (msg) {
grunt.fail.errorcount++;
- return this.writeln('>> '.red + grunt.util._.trim(msg).replace(/\n/g, '\n>> '.red));
+ return this.writeln('>> '.red + grunt.util._.trim(msg).replace(/\n/g, '\n>> '.red), process.stderr);
} else {
- return this.writeln('ERROR'.red);
+ return this.writeln('ERROR'.red, process.stderr);
}
};
log.ok = function(msg) {
@@ -75,7 +76,7 @@ log.ok = function(msg) {
log.errorlns = function(msg) { return this.error(log.wraptext(77, msg)); };
log.oklns = function(msg) { return this.ok(log.wraptext(77, msg)); };
log.success = function(msg) { return this.writeln(msg.green); };
-log.fail = function(msg) { return this.writeln(msg.red); };
+log.fail = function(msg) { return this.writeln(msg.red, process.stderr); };
log.header = function(msg) {
// Skip line before header, but not if header is the very first line output.
if (hasLogged) { this.writeln(); }
Something went wrong with that request. Please try again.