Get current console output to work with

Hello,

I would like to get the output printed in console tab for the current project, so I can parse it and later do some things with it. Where and how can I find the current console instance and the output that it contains?

Also is there a way to add a listener to the console, so everytime a change is made (new lines in console output) I get notified?

Thanks for the help.

Jan

6 comments
Comment actions Permalink

Thank you, it helped a lot.

But I have another question - is there a way to say when the process which is outputing on the console finished? Other than reading and parsing the text of the output?

Thanks in advance.

0
Comment actions Permalink

And one more question, which I thought of when working with the solution written in that comment, this seems to work only when I am using the console for the 2nd and more times. For the 1st time, nothing happens, as processStarted method does not work for this apparently.

Which method should I override and implement so that I can use the text from the console from the 1st time something is executed and outputs on console? 

Thanks in advance

0
Comment actions Permalink

Sure, when you add a ProcessListener to the ProcessHandler you can listen to termination event.

1
Comment actions Permalink

You can subscribe to ExecutionManager.EXECUTION_TOPIC in advance, when IDE just has started. So you'll be able to get every output line you need.

0
Comment actions Permalink

Thanks very much for your answers, but the one about 1st start of console is still something I have issues with.

I am using the ExecutionManager.EXECUTION_TOPIC and the
        public void processStarted(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler) method, where I add new ProcessListener. This listener though seems to work only from the 2nd+ run of programs which output on console. I debugged it and the handler adds Process Listener, but nothing happens the 1st time. Only the 2nd+ run the added ProcessAdapter works. 

Is there a way to register this listener when the Process is starting or what is the issue, as I dont understand, why the listener seems to work only after 2nd time.

Thanks in advance.

1

Please sign in to leave a comment.