aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java26
-rw-r--r--src/core/lombok/extern/apachecommons/CommonsLog.java4
-rw-r--r--src/core/lombok/extern/java/Log.java4
-rw-r--r--src/core/lombok/extern/log4j/Log4j.java4
-rw-r--r--src/core/lombok/extern/log4j/Log4j2.java4
-rw-r--r--src/core/lombok/extern/slf4j/Slf4j.java4
-rw-r--r--src/core/lombok/extern/slf4j/XSlf4j.java4
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java40
-rw-r--r--test/transform/resource/after-delombok/LoggerCommons.java4
-rw-r--r--test/transform/resource/after-delombok/LoggerJul.java4
-rw-r--r--test/transform/resource/after-delombok/LoggerLog4j.java4
-rw-r--r--test/transform/resource/after-delombok/LoggerLog4j2.java4
-rw-r--r--test/transform/resource/after-delombok/LoggerSlf4j.java5
-rw-r--r--test/transform/resource/after-delombok/LoggerXSlf4j.java4
-rw-r--r--test/transform/resource/after-ecj/LoggerCommons.java8
-rw-r--r--test/transform/resource/after-ecj/LoggerJul.java8
-rw-r--r--test/transform/resource/after-ecj/LoggerLog4j.java8
-rw-r--r--test/transform/resource/after-ecj/LoggerLog4j2.java8
-rw-r--r--test/transform/resource/after-ecj/LoggerSlf4j.java9
-rw-r--r--test/transform/resource/after-ecj/LoggerXSlf4j.java8
-rw-r--r--test/transform/resource/before/LoggerCommons.java6
-rw-r--r--test/transform/resource/before/LoggerJul.java4
-rw-r--r--test/transform/resource/before/LoggerLog4j.java4
-rw-r--r--test/transform/resource/before/LoggerLog4j2.java4
-rw-r--r--test/transform/resource/before/LoggerSlf4j.java4
-rw-r--r--test/transform/resource/before/LoggerXSlf4j.java4
-rw-r--r--usage_examples/LogExample_post.jpage8
-rw-r--r--usage_examples/LogExample_pre.jpage8
-rw-r--r--website/features/Log.html2
30 files changed, 182 insertions, 27 deletions
diff --git a/AUTHORS b/AUTHORS
index 8758bf40..32369734 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -7,5 +7,6 @@ Robbert Jan Grootjans <grootjans@gmail.com>
Roel Spilker <r.spilker@gmail.com>
Sander Koning <askoning@gmail.com>
Taiki Sugawara <buzz.taiki@gmail.com>
+Maarten Mulders <mthmulders@users.noreply.github.com>
By adding your name to this list, you grant full and irrevocable copyright and patent indemnity to Project Lombok and all use of Project Lombok, and you certify that you have the right to do so for all commits you add to Project Lombok.
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java
index 6b1e94be..56160b39 100644
--- a/src/core/lombok/eclipse/handlers/HandleLog.java
+++ b/src/core/lombok/eclipse/handlers/HandleLog.java
@@ -38,6 +38,7 @@ import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.StringLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
@@ -48,7 +49,7 @@ public class HandleLog {
throw new UnsupportedOperationException();
}
- public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
+ public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode, String loggerCategory) {
EclipseNode owner = annotationNode.up();
switch (owner.getKind()) {
case TYPE:
@@ -71,7 +72,7 @@ public class HandleLog {
ClassLiteralAccess loggingType = selfType(owner, source);
- FieldDeclaration fieldDeclaration = createField(framework, source, loggingType);
+ FieldDeclaration fieldDeclaration = createField(framework, source, loggingType, loggerCategory);
fieldDeclaration.traverse(new SetGeneratedByVisitor(source), typeDecl.staticInitializerScope);
// TODO temporary workaround for issue 217. http://code.google.com/p/projectlombok/issues/detail?id=217
// injectFieldSuppressWarnings(owner, fieldDeclaration);
@@ -97,7 +98,7 @@ public class HandleLog {
return result;
}
- public static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType) {
+ public static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String loggerCategory) {
int pS = source.sourceStart, pE = source.sourceEnd;
long p = (long)pS << 32 | pE;
@@ -116,7 +117,12 @@ public class HandleLog {
factoryMethodCall.receiver = createNameReference(framework.getLoggerFactoryTypeName(), source);
factoryMethodCall.selector = framework.getLoggerFactoryMethodName().toCharArray();
- Expression parameter = framework.createFactoryParameter(loggingType, source);
+ Expression parameter;
+ if (loggerCategory == null || loggerCategory.trim().length() == 0) {
+ parameter = framework.createFactoryParameter(loggingType, source);
+ } else {
+ parameter = new StringLiteral(loggerCategory.toCharArray(), pS, pE, 0);
+ }
factoryMethodCall.arguments = new Expression[] { parameter };
factoryMethodCall.nameSourcePosition = p;
@@ -155,7 +161,7 @@ public class HandleLog {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleCommonsLog extends EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
- processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode);
+ processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode, annotation.getInstance().value());
}
}
@@ -165,7 +171,7 @@ public class HandleLog {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleJulLog extends EclipseAnnotationHandler<lombok.extern.java.Log> {
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
- processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode);
+ processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode, annotation.getInstance().value());
}
}
@@ -175,7 +181,7 @@ public class HandleLog {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleLog4jLog extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
- processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode);
+ processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode, annotation.getInstance().value());
}
}
@@ -185,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());
}
}
@@ -195,7 +201,7 @@ public class HandleLog {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) {
- processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode);
+ processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode, annotation.getInstance().value());
}
}
@@ -205,7 +211,7 @@ public class HandleLog {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleXSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, Annotation source, EclipseNode annotationNode) {
- processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode);
+ processAnnotation(LoggingFramework.XSLF4J, annotation, source, annotationNode, annotation.getInstance().value());
}
}
diff --git a/src/core/lombok/extern/apachecommons/CommonsLog.java b/src/core/lombok/extern/apachecommons/CommonsLog.java
index 024e3744..34ac0fe6 100644
--- a/src/core/lombok/extern/apachecommons/CommonsLog.java
+++ b/src/core/lombok/extern/apachecommons/CommonsLog.java
@@ -59,4 +59,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface CommonsLog {
+ /**
+ * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed.
+ */
+ String value() default "";
} \ No newline at end of file
diff --git a/src/core/lombok/extern/java/Log.java b/src/core/lombok/extern/java/Log.java
index 7ae4e07b..dfa2e2aa 100644
--- a/src/core/lombok/extern/java/Log.java
+++ b/src/core/lombok/extern/java/Log.java
@@ -58,4 +58,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Log {
+ /**
+ * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed.
+ */
+ String value() default "";
} \ No newline at end of file
diff --git a/src/core/lombok/extern/log4j/Log4j.java b/src/core/lombok/extern/log4j/Log4j.java
index 29e1b27c..0fe74599 100644
--- a/src/core/lombok/extern/log4j/Log4j.java
+++ b/src/core/lombok/extern/log4j/Log4j.java
@@ -59,4 +59,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Log4j {
+ /**
+ * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed.
+ */
+ String value() default "";
} \ No newline at end of file
diff --git a/src/core/lombok/extern/log4j/Log4j2.java b/src/core/lombok/extern/log4j/Log4j2.java
index 2a0f09e1..96fab793 100644
--- a/src/core/lombok/extern/log4j/Log4j2.java
+++ b/src/core/lombok/extern/log4j/Log4j2.java
@@ -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 "";
} \ No newline at end of file
diff --git a/src/core/lombok/extern/slf4j/Slf4j.java b/src/core/lombok/extern/slf4j/Slf4j.java
index 8490b6b6..c4495990 100644
--- a/src/core/lombok/extern/slf4j/Slf4j.java
+++ b/src/core/lombok/extern/slf4j/Slf4j.java
@@ -57,4 +57,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Slf4j {
+ /**
+ * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed.
+ */
+ String value() default "";
}
diff --git a/src/core/lombok/extern/slf4j/XSlf4j.java b/src/core/lombok/extern/slf4j/XSlf4j.java
index 599c68ab..306057f0 100644
--- a/src/core/lombok/extern/slf4j/XSlf4j.java
+++ b/src/core/lombok/extern/slf4j/XSlf4j.java
@@ -57,4 +57,8 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface XSlf4j {
+ /**
+ * Sets the category of the constructed Logger. By default, it will use the type where the annotation is placed.
+ */
+ String value() default "";
}
diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java
index cb22496e..12b0cb5c 100644
--- a/src/core/lombok/javac/handlers/HandleLog.java
+++ b/src/core/lombok/javac/handlers/HandleLog.java
@@ -25,7 +25,9 @@ import static lombok.javac.handlers.JavacHandlerUtil.*;
import java.lang.annotation.Annotation;
+import lombok.NoArgsConstructor;
import lombok.core.AnnotationValues;
+import lombok.extern.slf4j.Slf4j;
import lombok.javac.JavacAnnotationHandler;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
@@ -47,10 +49,10 @@ public class HandleLog {
private HandleLog() {
throw new UnsupportedOperationException();
}
-
- public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode) {
+
+ public static void processAnnotation(LoggingFramework framework, AnnotationValues<?> annotation, JavacNode annotationNode, String loggerCategory) {
deleteAnnotationIfNeccessary(annotationNode, framework.getAnnotationClass());
-
+
JavacNode typeNode = annotationNode.up();
switch (typeNode.getKind()) {
case TYPE:
@@ -58,14 +60,14 @@ public class HandleLog {
annotationNode.addError("@Log is legal only on classes and enums.");
return;
}
-
+
if (fieldExists("log", typeNode)!= MemberExistsResult.NOT_EXISTS) {
annotationNode.addWarning("Field 'log' already exists.");
return;
}
-
+
JCFieldAccess loggingType = selfType(typeNode);
- createField(framework, typeNode, loggingType, annotationNode.get());
+ createField(framework, typeNode, loggingType, annotationNode.get(), loggerCategory);
break;
default:
annotationNode.addError("@Log is legal only on types.");
@@ -79,16 +81,22 @@ public class HandleLog {
return maker.Select(maker.Ident(name), typeNode.toName("class"));
}
- public static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source) {
+ public static boolean createField(LoggingFramework framework, JavacNode typeNode, JCFieldAccess loggingType, JCTree source, String loggerCategory) {
JavacTreeMaker maker = typeNode.getTreeMaker();
// private static final <loggerType> log = <factoryMethod>(<parameter>);
JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName());
JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName());
-
- JCExpression loggerName = framework.createFactoryParameter(typeNode, loggingType);
+
+ JCExpression loggerName;
+ if (loggerCategory == null || loggerCategory.trim().length() == 0) {
+ loggerName = framework.createFactoryParameter(typeNode, loggingType);
+ } else {
+ loggerName = maker.Literal(loggerCategory);
+ }
+
JCMethodInvocation factoryMethodCall = maker.Apply(List.<JCExpression>nil(), factoryMethod, List.<JCExpression>of(loggerName));
-
+
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | Flags.STATIC),
typeNode.toName("log"), loggerType, factoryMethodCall), source, typeNode.getContext());
@@ -103,7 +111,7 @@ public class HandleLog {
@ProviderFor(JavacAnnotationHandler.class)
public static class HandleCommonsLog extends JavacAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
@Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, JCAnnotation ast, JavacNode annotationNode) {
- processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode);
+ processAnnotation(LoggingFramework.COMMONS, annotation, annotationNode, annotation.getInstance().value());
}
}
@@ -113,7 +121,7 @@ public class HandleLog {
@ProviderFor(JavacAnnotationHandler.class)
public static class HandleJulLog extends JavacAnnotationHandler<lombok.extern.java.Log> {
@Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, JCAnnotation ast, JavacNode annotationNode) {
- processAnnotation(LoggingFramework.JUL, annotation, annotationNode);
+ processAnnotation(LoggingFramework.JUL, annotation, annotationNode, annotation.getInstance().value());
}
}
@@ -123,7 +131,7 @@ public class HandleLog {
@ProviderFor(JavacAnnotationHandler.class)
public static class HandleLog4jLog extends JavacAnnotationHandler<lombok.extern.log4j.Log4j> {
@Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
- processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode);
+ processAnnotation(LoggingFramework.LOG4J, annotation, annotationNode, annotation.getInstance().value());
}
}
@@ -133,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());
}
}
@@ -143,7 +151,7 @@ public class HandleLog {
@ProviderFor(JavacAnnotationHandler.class)
public static class HandleSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.Slf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
- processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode);
+ processAnnotation(LoggingFramework.SLF4J, annotation, annotationNode, annotation.getInstance().value());
}
}
@@ -153,7 +161,7 @@ public class HandleLog {
@ProviderFor(JavacAnnotationHandler.class)
public static class HandleXSlf4jLog extends JavacAnnotationHandler<lombok.extern.slf4j.XSlf4j> {
@Override public void handle(AnnotationValues<lombok.extern.slf4j.XSlf4j> annotation, JCAnnotation ast, JavacNode annotationNode) {
- processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode);
+ processAnnotation(LoggingFramework.XSLF4J, annotation, annotationNode, annotation.getInstance().value());
}
}
diff --git a/test/transform/resource/after-delombok/LoggerCommons.java b/test/transform/resource/after-delombok/LoggerCommons.java
index 6feea5b6..32ace53a 100644
--- a/test/transform/resource/after-delombok/LoggerCommons.java
+++ b/test/transform/resource/after-delombok/LoggerCommons.java
@@ -5,4 +5,8 @@ class LoggerCommons {
class LoggerCommonsWithImport {
@java.lang.SuppressWarnings("all")
private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(LoggerCommonsWithImport.class);
+}
+class LoggerCommonsWithDifferentName {
+ @java.lang.SuppressWarnings("all")
+ private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName");
} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerJul.java b/test/transform/resource/after-delombok/LoggerJul.java
index 20f0d24d..ad119777 100644
--- a/test/transform/resource/after-delombok/LoggerJul.java
+++ b/test/transform/resource/after-delombok/LoggerJul.java
@@ -5,4 +5,8 @@ class LoggerJul {
class LoggerJulWithImport {
@java.lang.SuppressWarnings("all")
private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger(LoggerJulWithImport.class.getName());
+}
+class LoggerJulWithDifferentName {
+ @java.lang.SuppressWarnings("all")
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName");
} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerLog4j.java b/test/transform/resource/after-delombok/LoggerLog4j.java
index 7d54b259..99eac34f 100644
--- a/test/transform/resource/after-delombok/LoggerLog4j.java
+++ b/test/transform/resource/after-delombok/LoggerLog4j.java
@@ -5,4 +5,8 @@ class LoggerLog4j {
class LoggerLog4jWithImport {
@java.lang.SuppressWarnings("all")
private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(LoggerLog4jWithImport.class);
+}
+class LoggerLog4jWithDifferentName {
+ @java.lang.SuppressWarnings("all")
+ private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName");
} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerLog4j2.java b/test/transform/resource/after-delombok/LoggerLog4j2.java
index 7e4c01de..8473134b 100644
--- a/test/transform/resource/after-delombok/LoggerLog4j2.java
+++ b/test/transform/resource/after-delombok/LoggerLog4j2.java
@@ -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");
} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerSlf4j.java b/test/transform/resource/after-delombok/LoggerSlf4j.java
index a07c8546..3c6e6d2f 100644
--- a/test/transform/resource/after-delombok/LoggerSlf4j.java
+++ b/test/transform/resource/after-delombok/LoggerSlf4j.java
@@ -11,4 +11,9 @@ class LoggerSlf4jOuter {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(Inner.class);
}
+}
+
+class LoggerSlf4jWithDifferentLoggerName {
+ @java.lang.SuppressWarnings("all")
+ private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger");
} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/LoggerXSlf4j.java b/test/transform/resource/after-delombok/LoggerXSlf4j.java
index 981bcca6..d0654b51 100644
--- a/test/transform/resource/after-delombok/LoggerXSlf4j.java
+++ b/test/transform/resource/after-delombok/LoggerXSlf4j.java
@@ -5,4 +5,8 @@ class LoggerXSlf4j {
class LoggerXSlf4jWithImport {
@java.lang.SuppressWarnings("all")
private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger(LoggerXSlf4jWithImport.class);
+}
+class LoggerXSlf4jWithDifferentName {
+ @java.lang.SuppressWarnings("all")
+ private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName");
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerCommons.java b/test/transform/resource/after-ecj/LoggerCommons.java
index d63bb9c1..50d07a14 100644
--- a/test/transform/resource/after-ecj/LoggerCommons.java
+++ b/test/transform/resource/after-ecj/LoggerCommons.java
@@ -14,4 +14,12 @@ import lombok.extern.apachecommons.CommonsLog;
LoggerCommonsWithImport() {
super();
}
+}
+@CommonsLog("DifferentName") class LoggerCommonsWithDifferentName {
+ private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("DifferentName");
+ <clinit>() {
+ }
+ LoggerCommonsWithDifferentName() {
+ super();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerJul.java b/test/transform/resource/after-ecj/LoggerJul.java
index c98dfe27..3aa8181d 100644
--- a/test/transform/resource/after-ecj/LoggerJul.java
+++ b/test/transform/resource/after-ecj/LoggerJul.java
@@ -14,4 +14,12 @@ import lombok.extern.java.Log;
LoggerJulWithImport() {
super();
}
+}
+@Log("DifferentName") class LoggerJulWithDifferentName {
+ private static final java.util.logging.Logger log = java.util.logging.Logger.getLogger("DifferentName");
+ <clinit>() {
+ }
+ LoggerJulWithDifferentName() {
+ super();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerLog4j.java b/test/transform/resource/after-ecj/LoggerLog4j.java
index 6814be7b..a6c52d61 100644
--- a/test/transform/resource/after-ecj/LoggerLog4j.java
+++ b/test/transform/resource/after-ecj/LoggerLog4j.java
@@ -14,4 +14,12 @@ import lombok.extern.log4j.Log4j;
LoggerLog4jWithImport() {
super();
}
+}
+@Log4j("DifferentName") class LoggerLog4jWithDifferentName {
+ private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("DifferentName");
+ <clinit>() {
+ }
+ LoggerLog4jWithDifferentName() {
+ super();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerLog4j2.java b/test/transform/resource/after-ecj/LoggerLog4j2.java
index c1368e5d..3243ef2d 100644
--- a/test/transform/resource/after-ecj/LoggerLog4j2.java
+++ b/test/transform/resource/after-ecj/LoggerLog4j2.java
@@ -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();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerSlf4j.java b/test/transform/resource/after-ecj/LoggerSlf4j.java
index 1ccf5c9e..a34f85d7 100644
--- a/test/transform/resource/after-ecj/LoggerSlf4j.java
+++ b/test/transform/resource/after-ecj/LoggerSlf4j.java
@@ -27,4 +27,13 @@ class LoggerSlf4jOuter {
LoggerSlf4jOuter() {
super();
}
+}
+
+@Slf4j("DifferentLogger") class LoggerSlf4jWithDifferentLoggerName {
+ private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger("DifferentLogger");
+ <clinit>() {
+ }
+ LoggerSlf4jWithDifferentLoggerName() {
+ super();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/LoggerXSlf4j.java b/test/transform/resource/after-ecj/LoggerXSlf4j.java
index f05e1ae7..4cd4cb94 100644
--- a/test/transform/resource/after-ecj/LoggerXSlf4j.java
+++ b/test/transform/resource/after-ecj/LoggerXSlf4j.java
@@ -14,4 +14,12 @@ import lombok.extern.slf4j.XSlf4j;
LoggerXSlf4jWithImport() {
super();
}
+}
+@XSlf4j("DifferentName") class LoggerXSlf4jWithDifferentName {
+ private static final org.slf4j.ext.XLogger log = org.slf4j.ext.XLoggerFactory.getXLogger("DifferentName");
+ <clinit>() {
+ }
+ LoggerXSlf4jWithDifferentName() {
+ super();
+ }
} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerCommons.java b/test/transform/resource/before/LoggerCommons.java
index 52210d25..ce9e4ec4 100644
--- a/test/transform/resource/before/LoggerCommons.java
+++ b/test/transform/resource/before/LoggerCommons.java
@@ -6,4 +6,8 @@ class LoggerCommons {
@CommonsLog
class LoggerCommonsWithImport {
-} \ No newline at end of file
+}
+
+@CommonsLog("DifferentName")
+class LoggerCommonsWithDifferentName {
+}
diff --git a/test/transform/resource/before/LoggerJul.java b/test/transform/resource/before/LoggerJul.java
index 52869e81..41e36220 100644
--- a/test/transform/resource/before/LoggerJul.java
+++ b/test/transform/resource/before/LoggerJul.java
@@ -6,4 +6,8 @@ class LoggerJul {
@Log
class LoggerJulWithImport {
+}
+
+@Log("DifferentName")
+class LoggerJulWithDifferentName {
} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerLog4j.java b/test/transform/resource/before/LoggerLog4j.java
index 03735bff..fa7dad4a 100644
--- a/test/transform/resource/before/LoggerLog4j.java
+++ b/test/transform/resource/before/LoggerLog4j.java
@@ -6,4 +6,8 @@ class LoggerLog4j {
@Log4j
class LoggerLog4jWithImport {
+}
+
+@Log4j("DifferentName")
+class LoggerLog4jWithDifferentName {
} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerLog4j2.java b/test/transform/resource/before/LoggerLog4j2.java
index b7ea99ee..13b3605f 100644
--- a/test/transform/resource/before/LoggerLog4j2.java
+++ b/test/transform/resource/before/LoggerLog4j2.java
@@ -6,4 +6,8 @@ class LoggerLog4j2 {
@Log4j2
class LoggerLog4j2WithImport {
+}
+
+@Log4j2("DifferentName")
+class LoggerLog4j2WithDifferentName {
} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerSlf4j.java b/test/transform/resource/before/LoggerSlf4j.java
index 133ee36e..b620e056 100644
--- a/test/transform/resource/before/LoggerSlf4j.java
+++ b/test/transform/resource/before/LoggerSlf4j.java
@@ -13,4 +13,8 @@ class LoggerSlf4jOuter {
static class Inner {
}
+}
+
+@Slf4j("DifferentLogger")
+class LoggerSlf4jWithDifferentLoggerName {
} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerXSlf4j.java b/test/transform/resource/before/LoggerXSlf4j.java
index 6dbbf2d1..408bd134 100644
--- a/test/transform/resource/before/LoggerXSlf4j.java
+++ b/test/transform/resource/before/LoggerXSlf4j.java
@@ -6,4 +6,8 @@ class LoggerXSlf4j {
@XSlf4j
class LoggerXSlf4jWithImport {
+}
+
+@XSlf4j("DifferentName")
+class LoggerXSlf4jWithDifferentName {
} \ No newline at end of file
diff --git a/usage_examples/LogExample_post.jpage b/usage_examples/LogExample_post.jpage
index 4ab35b08..eab3b046 100644
--- a/usage_examples/LogExample_post.jpage
+++ b/usage_examples/LogExample_post.jpage
@@ -13,3 +13,11 @@ public class LogExampleOther {
log.error("Something else is wrong here");
}
}
+
+public class LogExampleCategory {
+ private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("CounterLog");
+
+ public static void main(String... args) {
+ log.error("Calling the 'CounterLog' with a message");
+ }
+}
diff --git a/usage_examples/LogExample_pre.jpage b/usage_examples/LogExample_pre.jpage
index 196a9047..fa746dba 100644
--- a/usage_examples/LogExample_pre.jpage
+++ b/usage_examples/LogExample_pre.jpage
@@ -16,3 +16,11 @@ public class LogExampleOther {
log.error("Something else is wrong here");
}
}
+
+@CommonsLog("CounterLog")
+public class LogExampleCategory {
+
+ public static void main(String... args) {
+ log.error("Calling the 'CounterLog' with a message");
+ }
+}
diff --git a/website/features/Log.html b/website/features/Log.html
index f92af1e3..e6b3ece6 100644
--- a/website/features/Log.html
+++ b/website/features/Log.html
@@ -33,6 +33,8 @@
<dt><code>@XSlf4j</code></dt>
<dd>Creates <code><span class="keyword">private&nbsp;static&nbsp;final&nbsp;</span><a href="http://www.slf4j.org/api/org/slf4j/ext/XLogger.html">org.slf4j.ext.XLogger</a>&nbsp;<span class="staticfield">log</span>&nbsp;=&nbsp;<a href="http://www.slf4j.org/apidocs/org/slf4j/ext/XLoggerFactory.html#getXLogger(java.lang.Class)">org.slf4j.ext.XLoggerFactory.getXLogger</a>(LogExample.<span class="keyword">class</span>);</code></dd>
</dl>
+ </p><p>
+ By default, the category (or name) of the logger will be the type where the annotation was placed. This can be customised by specifying a value for the category.
</p>
</div>
<div class="snippets">