Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4350

@Log annotation should be extensible by users and other frameworks

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8-beta-1
    • 1.8-beta-3
    • groovy-jdk
    • None
    • all
    • Patch

    Description

      The @Log family of annotations adds explicit support to Groovy for java.util.Logging, Commons Loggins, slf4j, and log4j. It was written and tested against the latest versions of these libraries.

      In order to "future proof" the feature, we need to allow other frameworks to participate in the @Log annotations as well.

      The attached patch allows users to easily write their own logging extensions. The 4 frameworks supported today use this exact mechanism to to their own work.

      The difference between logging frameworks is hidden behind a strategy pattern called:
      org.codehaus.groovy.transform.LogASTTransformation.LoggingStrategy

      To define your own @Log style logger support, your @LogX annotation must have the following attribute:
      Class<? extends LoggingStrategy> loggingStrategy() default MyLoggingStrategy.class;

      And MyLoggingStrategy must be available at compile time. This class just needs to implement the interface correctly.

      The complete patch is attached.

      Attachments

        1. LogAnnotationExtensions.patch
          23 kB
          Hamlet D'Arcy

        Activity

          People

            hamletdrc Hamlet D'Arcy
            hamletdrc Hamlet D'Arcy
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified