Permalink
Browse files

Update LoggingTransformer AST to use SLF4J

  • Loading branch information...
1 parent 639d703 commit dec43eea25ddee2fd5bdb98d8f4881cf1e7a1570 @dpcasady dpcasady committed Mar 24, 2016
@@ -15,8 +15,8 @@
*/
package org.grails.compiler.logging;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.FieldNode;
import org.codehaus.groovy.ast.expr.ArgumentListExpression;
@@ -65,9 +65,9 @@ public void performInjection(SourceUnit source, GeneratorContext context, ClassN
public static void addLogField(ClassNode classNode, String logName) {
FieldNode logVariable = new FieldNode(LOG_PROPERTY,
Modifier.STATIC | Modifier.PRIVATE,
- new ClassNode(Log.class),
+ new ClassNode(Logger.class),
classNode,
- new MethodCallExpression(new ClassExpression(new ClassNode(LogFactory.class)), "getLog", new ArgumentListExpression(new ConstantExpression(logName))));
+ new MethodCallExpression(new ClassExpression(new ClassNode(LoggerFactory.class)), "getLogger", new ArgumentListExpression(new ConstantExpression(logName))));
classNode.addField(logVariable);
}
@@ -1,6 +1,6 @@
package org.grails.compiler.logging
-import org.apache.commons.logging.Log
+import org.slf4j.Logger
import grails.compiler.ast.ClassInjector
import org.grails.compiler.injection.GrailsAwareClassLoader
import spock.lang.Specification
@@ -27,10 +27,10 @@ class LoggingController extends BaseController{
}
''', "foo/grails-app/controllers/LoggingController.groovy")
def controller = cls.newInstance()
- Log log = controller.index()
+ Logger log = controller.index()
then:
- log instanceof Log
+ log instanceof Logger
}
def "Test added log field"() {
given:
@@ -48,10 +48,10 @@ class LoggingController {
}
''', "foo/grails-app/controllers/LoggingController.groovy")
def controller = cls.newInstance()
- Log log = controller.index()
+ Logger log = controller.index()
then:
- log instanceof Log
+ log instanceof Logger
}
@@ -69,10 +69,10 @@ class LoggingController {
}
''', "foo/grails-app/controllers/LoggingController.groovy")
def controller = cls.newInstance()
- Log log = controller.index()
+ Logger log = controller.index()
then:
- log instanceof Log
+ log instanceof Logger
}
}
@@ -1,6 +1,6 @@
package grails.test.mixin
-import org.apache.commons.logging.Log
+import org.slf4j.Logger
import org.junit.Test
import spock.lang.Specification
@@ -14,7 +14,7 @@ class TestForSpec extends Specification{
then:
test != null
test.getClass().getDeclaredMethod("testIndex", null).getAnnotation(Test.class) != null
- test.retrieveLog() instanceof Log
+ test.retrieveLog() instanceof Logger
}
void "Test junit 3 test doesn't get annotation"() {
@@ -24,7 +24,7 @@ class TestForSpec extends Specification{
then:
test != null
test.getClass().getDeclaredMethod("testIndex", null).getAnnotation(Test.class) == null
- test.retrieveLog() instanceof Log
+ test.retrieveLog() instanceof Logger
}
void "Test spock test doesn't get annotation"() {
@@ -33,7 +33,7 @@ class TestForSpec extends Specification{
then:
test != null
- test.retrieveLog() instanceof Log
+ test.retrieveLog() instanceof Logger
}
def getSpockTest() {

0 comments on commit dec43ee

Please sign in to comment.