Grails:如何在cmd控制台中打印? [英] Grails: How do I print in the cmd console?

查看:110
本文介绍了Grails:如何在cmd控制台中打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在控制台中打印一些值,该怎么做?

I wanna print a few values in the console, how do I do this?

每次进入函数时,我都希望它打印一行无论是什么文本,我只是想知道我是否正在进入该函数以及一些if-else语句。
主要用于调试。

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.

推荐答案

您可能要考虑内置于日志记录功能的grails,该功能提供与println相同的功能。以及更多

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

您的应用只是说

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 = {
    }
}

由于控制器拦截器

这篇关于Grails:如何在cmd控制台中打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆