views:

27

answers:

2

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.

A: 

If you mean "print to the console output panel", then you simply need to use println:

1 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?

Rob Hruska
I updated the question
fgualda87
Yeah, `println` should work.
Rob Hruska
A: 

you might want to consider grails built in logging functionality which provides the same functionality as println plus more

http://www.grails.org/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

Aaron Saunders