How do you get the logger in a RuleSource plugin to print a warning?

plugins

(Appu Goundan) #1

I don’t seem to have access the project object to call getLogger(). I could a java util logger which gradle seems to accept log lines from, what’s gradle mechanism here for printing a warning in a RuleSource initialization? Is there some way to inject it into a method like?

@Defaults
public void setDefaults(Logger logger) {
 logger.warn("hi")
}

(Mark Vieira) #2

You can get a Logger instance via a static cal to getLogger() on the Logging class. This should allow you to log from any code of yours, not just code that has a handle to a Gradle domain object like Task or Project.