I wanna print a few values in the console, how do I do this?
Every time I get into a function, I want it to print a line with whatever text, I just wanna know if I'm getting into the function, and for some if-else statements. Mostly for debugging.
If you mean "print to the console output panel", then you simply need to use println
:
println "Hello, world"
Results in printed output:
groovy> println "Hello, world"
Hello, world
If that's not what you mean, can you clarify your question to be more specific?
you might want to consider grails built in logging functionality which provides the same functionality as println plus more
http://grails.github.io/grails-doc/3.0.x/guide/single.html#logging
in your app just say
log.info "Hello World"
to print something everytime you enter an action in a controller you can do something like this
class UserController {
def beforeInterceptor = {
log.info "Entering Action ${actionUri}"
}
def index = {
}
def listContributors = {
}
}
this will print out to the log whenever the controller methods are entered because of the controller interceptor
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With