How can I debug intellij gdsl files?
How can I debug inte开发者_Python百科llij gdsl files?
Use println. In order to see the console output, you should first start IDEA from within a script (idea.bat or idea.sh).
Although this question is quite old, it might still help, since the whole gdsl part is extremely powerful but also extremely bad documented.
You can access the Logger via OpenApi from any gdsl file (although usually without code completion unless you include the openapi artifact in your project):
import com.intellij.openapi.diagnostic.Logger
def ctx = context(scope:closureScope())
contributor(ctx) {
Logger.getInstance("my-psi").info("I am here")
}
The result will be in the intellij system log (Help -> Show Log in Explorer). There you can tail / grep / whatever.
Alternatively, use log4j
with a FileAppender
(or similar). I've used something like this for setting up log4j
in the gdsl
file:
class Helper{
static def LOG = Logger.getLogger( "my.gdsl" )
static
{
Logger.getRootLogger().setLevel( Level.INFO ) //as needed
BasicConfigurator.configure new FileAppender( new PatternLayout( "%5p[%d] %c %m%n\n" ), "/tmp/my-gdsl.log" )
}
}
and to emit log info:
Helper.LOG.info "wassup?"
精彩评论