GGTS: Clean up Grails 2.0 output
Have you ever had in Groovy/Grails Tool Suite (GGTS) that console output, by a running Grails application, which is exactly the same as the previous output, just isnât displayed?
This can often be seen with println statements for debug-purposes e.g. in a Controller, which you think should output some line to the console every time, but simply doesnât.
class TestController {
def index() {
println "index called"
}
}When http://localhost:8080/test/test/index is invoked repeatedly in the browser, you just keep seeing only the first occurence.
....index called
When the same message repeatedly is sent to the console a certain convenience feature of GGTS swallows some output â if it looks the same. It has to do with the â since Grails 2.0 introduced â ANSI codes to make some output to the console coloured or re-appear on the same line.
Kris de Volder gives a nice example in JIRA issue STS-3499 about how multiple lines such as
Resolving Dependencies. Resolving Dependencies.. Resolving Dependencies... Resolving Dependencies....
are supposed to ârewrite over themselvesâ on ANSI-supported consoles, so youâd only see
Resolving Dependencies...<increasing periods>
on the same line.
Output in the GGTS non-ANSI-enabled console is stripped from these codes â which would result in additional output which some people find unpleasant. So GGTS uses a workaround â which is enabled by default â and strips the beginning of the output which matches previous output and only print the remainder.
So if you were wondering why
class BootStrap {
def init = { servletContext ->
['A', 'B', 'B'].each { println it }
}
}would only print
|Running Grails application A B |Server running. Browse to http://localhost:8080/test
instead of
|Running Grails application A B B |Server running. Browse to http://localhost:8080/test
you know now this is not a bug :-)
You have to disable the option âClean Grails 2.0 outputâ in the GGTS preferences under Groovy > Grails > Grails Launch to prevent this swallowing-behaviour.
Now your output appears in GGTS when you want it to appear :-)
| Reference: | GGTS: Clean up Grails 2.0 output from our JCG partner Ted Vinke at the Ted Vinke’s Blog blog. |






