Handler and testcases for @Log4j2

This commit is contained in:
Maarten Mulders committed 2014-02-08 20:24:23 +01:00
1 parent ebc9ee5f6d
commit 1045006fa9
6 files changed
+22 -2

No files matched your search

@@ -191,7 +191,7 @@ public class HandleLog {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleLog4j2Log extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j2> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, Annotation source, EclipseNode annotationNode) {
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, "");
processAnnotation(LoggingFramework.LOG4J2, annotation, source, annotationNode, annotation.getInstance().value());
}
}
+4
View File
@@ -59,4 +59,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Log4j2 {
/**
* Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed.
*/
String value() default "";
}
@@ -141,7 +141,7 @@ public class HandleLog {
@ProviderFor(JavacAnnotationHandler.class)
public static class HandleLog4j2Log extends JavacAnnotationHandler<lombok.extern.log4j.Log4j2> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j2> annotation, JCAnnotation ast, JavacNode annotationNode) {
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, "");
processAnnotation(LoggingFramework.LOG4J2, annotation, annotationNode, annotation.getInstance().value());
}
}
@@ -5,4 +5,8 @@ class LoggerLog4j2 {
class LoggerLog4j2WithImport {
@java.lang.SuppressWarnings("all")
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger(LoggerLog4j2WithImport.class);
}
class LoggerLog4j2WithDifferentName {
@java.lang.SuppressWarnings("all")
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName");
}
@@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j2;
LoggerLog4j2WithImport() {
super();
}
}
@Log4j2("DifferentName") class LoggerLog4j2WithDifferentName {
private static final org.apache.logging.log4j.Logger log = org.apache.logging.log4j.LogManager.getLogger("DifferentName");
<clinit>() {
}
LoggerLog4j2WithDifferentName() {
super();
}
}
@@ -6,4 +6,8 @@ class LoggerLog4j2 {
@Log4j2
class LoggerLog4j2WithImport {
}
@Log4j2("DifferentName")
class LoggerLog4j2WithDifferentName {
}