log.debug { "$toStringMe only if necessary!" } - No Fluff Just Stuff

log.debug { "$toStringMe only if necessary!" }

Posted by: Robert Fischer on March 19, 2010

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/
Creative Commons License
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.

(Digital Fingerprint: bcecb67d74ab248f06f068724220e340 (69.147.112.169) )

Robert Fischer

About Robert Fischer

Robert Fischer is a multi-language open source developer currently specializing in Groovy in Grails. In the past, his specialties have been in Perl, Java, Ruby, and OCaml. In the future, his specialty will probably be F# or (preferably) a functional JVM language like Scala or Clojure.

Robert is the author of Grails Persistence in GORM and GSQL, a regular contributor to GroovyMag and JSMag, the founder of the JConch Java concurrency library, and the author/maintainer of Liquibase-DSL and the Autobase database migration plugin for Grails.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »