Intercepting STDOUT messages

Hi,

I am trying to intercept STDOUT messages to hide some extraneous logs from some underlying bad libraries.

Anyway, I tried to intercept logs very simply as follows:

def outputEventRenderer = gradle.services.get(LoggingOutputInternal) 
outputEventRenderer.addStandardOutputListener (new StandardOutputListener () {
    void onOutput(CharSequence output) {
        println("STDOUT Message intercepted: " + output.toString())
    }
})
outputEventRenderer.addStandardErrorListener (new StandardOutputListener () {
    void onOutput(CharSequence output) {
        println("STDERR Message intercepted: " + output.toString())
    }
})

This works fine for STDERR, but whenever I hijack the STDOUT listener, the gradle daemon always crashes. I don’t see anything in the logs that point me to what is wrong. Even no daemon mode is no good.

Does anyone see anything wrong in what I am doing?

Are there any alternatives to hijacking the StandardOutputListener? All I want to do is add a hook that says, if the output text contains some string, don’t print it.

I have tried this with gradle version 1.9 and 2.2.

tia,
rouble