-
Notifications
You must be signed in to change notification settings - Fork 282
Description
Hi all,
Context
My task runs a command line application.
The application produces:
- normal output to stdout
- logs, messages, errors to stderr.
I want my task to write
- normal output of the application to a file
- logs messages, errors to the stderr or stdout, which will end up on the WEB UI console.
I write to the file by subscribing in my task to ToolRunner
's stdout
event, which is not optimal but works. Providing file WriteStream
through options.outStream
does not work, as ToolRunner
would write both the application's stdout
and stderr
to that options.outStream
.
The problem
When I provide my task a filename input parameter, I want it to print standard output to the file only.
But the task library always prints the standard command output to the console.
The only way for me to make it not do it is to enable silent
mode. But silent
mode has drawbacks, such as, I don't see the command name anymore when it starts and also stderr is gone. I can solve stderr
issue by also subscribing to stderr
event and printing errors manually.
Possible solution
Instead of using silent
mode, ToolRunner
writes command errors to error stream and normal output to stdout.
Basically, in ToolRunner
, replace this :
if (!optionsNonNull.silent) {
var s = optionsNonNull.failOnStdErr ? optionsNonNull.errStream! : optionsNonNull.outStream!;
s.write(data);
}
with this:
if (!optionsNonNull.silent) {
optionsNonNull.errStream!.write(data);
}
Then I can pass my file's WriteStream
to options.outStream
.
Thanks.