I’ve just updated the @WithLog AST transform for Groovy. In case you don’t know, that’s my project over at GitHub which allows you to turn:
import org.apache.log4j.Logger class Foo { static log = Logger.getLogger(Foo) /* ... */ }
into
@WithLog class Foo { /* ... */ }
Three big changes in the new release. First, I switched to using Gradle for the build system, because Gradle is awesome. Second, I OSGi-ified the archive and released it to the Maven repo at http://repo.smokejumperit.com, so I’m now Java infrastructure compliant (thank you, Gradle, for making that a no-brainer). Third, I provided the ability to use an enhanced Logger implementation (unoriginally called WithLogLogger) — see the README for full details, but basically it means you can save the toString() evaluation on your logging messages if you wrap the logging GString in a Closure. If you use this, though, you’ll have to schlep around the Groovy-WithLog-0.2.jar file with your runtime code. If you’re using Maven/Ivy/Gradle/whatever, see the end of the README for repo information.
The @WithLog code is still released under the WTFPL.
This post was by Robert Fischer, written on March 19, 2010.
Comment on this post: http://enfranchisedmind.com/blog/posts/log-debug-tostringme-only-if-necessary/#respond
Public Permalink: http://enfranchisedmind.com/blog/posts/log-debug-tostringme-only-if-necessary/

This article was a post on the EnfranchisedMind blog. EnfranchisedMind Blog by Robert Fischer, Brian Hurt, and Other Authors is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.