mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 08:18:29 +00:00
Fixex #1697: google’s FluentLogger (Flogger) now available as one of lombok’s log annotations.
This commit is contained in:
1 parent
974e80e1de
commit
370705e7e1
19 files changed
+220
-19
No files matched your search
@@ -26,7 +26,8 @@
|
||||
<dependency org="commons-logging" name="commons-logging" rev="1.1.1" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.slf4j" name="slf4j-api" rev="1.6.1" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.slf4j" name="slf4j-ext" rev="1.6.1" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.jboss.logging" name="jboss-logging" rev="3.3.0.Final" conf="test->default; contrib->sources" />
|
||||
<dependency org="org.jboss.logging" name="jboss-logging" rev="3.3.0.Final" conf="test->default; contrib->sources" />
|
||||
<dependency org="com.google.flogger" name="flogger" rev="0.2" conf="test->default; contrib->sources" />
|
||||
|
||||
<dependency org="com.google.guava" name="guava" rev="18.0" conf="test->default; contrib->sources" />
|
||||
<dependency org="com.google.code.findbugs" name="findbugs" rev="3.0.0" conf="test->master" />
|
||||
|
||||
@@ -5,6 +5,7 @@ Lombok Changelog
|
||||
* v1.16.22 is the latest stable release of Project Lombok.
|
||||
* BUGFIX: Using boolean parameters in lombok annotations would fail. [Issue #1709](https://github.com/rzwitserloot/lombok/issues/1709)
|
||||
* BUGFIX: Delombok would give an error message. [Issue #1705](https://github.com/rzwitserloot/lombok/issues/1705)
|
||||
* FEATURE: Google's [Flogger (a.k.a. FluentLogger)](https://google.github.io/flogger/) is now available via `@Flogger`. [Issue #1697](https://github.com/rzwitserloot/lombok/issues/1697)
|
||||
|
||||
### v1.16.22 "Envious Ferret" (May 29th, 2018)
|
||||
* FEATURE: Private no-args constructor for `@Data` and `@Value` to enable deserialization frameworks (like Jackson) to operate out-of-the-box. Use `lombok.noArgsConstructor.extraPrivate = false` to disable this behavior.
|
||||
|
||||
@@ -389,6 +389,13 @@ public class ConfigurationKeys {
|
||||
*/
|
||||
public static final ConfigurationKey<FlagUsageType> LOG_JBOSSLOG_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.log.jbosslog.flagUsage", "Emit a warning or error if @JBossLog is used.") {};
|
||||
|
||||
/**
|
||||
* lombok configuration: {@code lombok.log.flogger.flagUsage} = {@code WARNING} | {@code ERROR}.
|
||||
*
|
||||
* If set, <em>any</em> usage of {@code @Flogger} results in a warning / error.
|
||||
*/
|
||||
public static final ConfigurationKey<FlagUsageType> LOG_FLOGGER_FLAG_USAGE = new ConfigurationKey<FlagUsageType>("lombok.log.flogger.flagUsage", "Emit a warning or error if @Flogger is used.") {};
|
||||
|
||||
/**
|
||||
* lombok configuration: {@code lombok.log.fieldName} = <String: aJavaIdentifier> (Default: {@code log}).
|
||||
*
|
||||
|
||||
@@ -109,7 +109,7 @@ public class HandleLog {
|
||||
|
||||
private static FieldDeclaration createField(LoggingFramework framework, Annotation source, ClassLiteralAccess loggingType, String logFieldName, boolean useStatic, String loggerTopic) {
|
||||
int pS = source.sourceStart, pE = source.sourceEnd;
|
||||
long p = (long)pS << 32 | pE;
|
||||
long p = (long) pS << 32 | pE;
|
||||
|
||||
// private static final <loggerType> log = <factoryMethod>(<parameter>);
|
||||
FieldDeclaration fieldDecl = new FieldDeclaration(logFieldName.toCharArray(), 0, -1);
|
||||
@@ -126,13 +126,15 @@ public class HandleLog {
|
||||
factoryMethodCall.selector = framework.getLoggerFactoryMethodName().toCharArray();
|
||||
|
||||
Expression parameter;
|
||||
if (loggerTopic == null || loggerTopic.trim().length() == 0) {
|
||||
if (!framework.passTypeName) {
|
||||
parameter = null;
|
||||
} else if (loggerTopic == null || loggerTopic.trim().length() == 0) {
|
||||
parameter = framework.createFactoryParameter(loggingType, source);
|
||||
} else {
|
||||
parameter = new StringLiteral(loggerTopic.toCharArray(), pS, pE, 0);
|
||||
}
|
||||
|
||||
factoryMethodCall.arguments = new Expression[] { parameter };
|
||||
factoryMethodCall.arguments = parameter != null ? new Expression[] { parameter } : null;
|
||||
factoryMethodCall.nameSourcePosition = p;
|
||||
factoryMethodCall.sourceStart = pS;
|
||||
factoryMethodCall.sourceEnd = factoryMethodCall.statementEnd = pE;
|
||||
@@ -240,6 +242,17 @@ public class HandleLog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link lombok.extern.flogger.Flogger} annotation for Eclipse.
|
||||
*/
|
||||
@ProviderFor(EclipseAnnotationHandler.class)
|
||||
public static class HandleFloggerLog extends EclipseAnnotationHandler<lombok.extern.flogger.Flogger> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, Annotation source, EclipseNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.FLOGGER, annotation, source, annotationNode, "");
|
||||
}
|
||||
}
|
||||
|
||||
enum LoggingFramework {
|
||||
// private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class);
|
||||
COMMONS("org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory", "getLog", "@CommonsLog"),
|
||||
@@ -278,18 +291,31 @@ public class HandleLog {
|
||||
|
||||
// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(TargetType.class);
|
||||
JBOSSLOG("org.jboss.logging.Logger", "org.jboss.logging.Logger", "getLogger", "@JBossLog"),
|
||||
|
||||
// private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
FLOGGER("com.google.common.flogger.FluentLogger", "com.google.common.flogger.FluentLogger", "forEnclosingClass", "@Flogger", false),
|
||||
;
|
||||
|
||||
private final String loggerTypeName;
|
||||
private final String loggerFactoryTypeName;
|
||||
private final String loggerFactoryMethodName;
|
||||
private final String annotationAsString;
|
||||
|
||||
private final boolean passTypeName;
|
||||
|
||||
LoggingFramework(String loggerTypeName, String loggerFactoryTypeName, String loggerFactoryMethodName, String annotationAsString, boolean passTypeName) {
|
||||
this.loggerTypeName = loggerTypeName;
|
||||
this.loggerFactoryTypeName = loggerFactoryTypeName;
|
||||
this.loggerFactoryMethodName = loggerFactoryMethodName;
|
||||
this.annotationAsString = annotationAsString;
|
||||
this.passTypeName = passTypeName;
|
||||
}
|
||||
|
||||
LoggingFramework(String loggerTypeName, String loggerFactoryTypeName, String loggerFactoryMethodName, String annotationAsString) {
|
||||
this.loggerTypeName = loggerTypeName;
|
||||
this.loggerFactoryTypeName = loggerFactoryTypeName;
|
||||
this.loggerFactoryMethodName = loggerFactoryMethodName;
|
||||
this.annotationAsString = annotationAsString;
|
||||
this.passTypeName = true;
|
||||
}
|
||||
|
||||
final String getAnnotationAsString() {
|
||||
@@ -308,7 +334,7 @@ public class HandleLog {
|
||||
return loggerFactoryMethodName;
|
||||
}
|
||||
|
||||
Expression createFactoryParameter(ClassLiteralAccess loggingType, Annotation source){
|
||||
Expression createFactoryParameter(ClassLiteralAccess loggingType, Annotation source) {
|
||||
TypeReference copy = copyType(loggingType.type, source);
|
||||
ClassLiteralAccess result = new ClassLiteralAccess(source.sourceEnd, copy);
|
||||
setGeneratedBy(result, source);
|
||||
|
||||
@@ -56,6 +56,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Project Lombok Authors.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package lombok.extern.flogger;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Causes lombok to generate a logger field.
|
||||
* <p>
|
||||
* Complete documentation is found at <a href="https://projectlombok.org/features/Log">the project lombok features page for lombok log annotations</a>.
|
||||
* <p>
|
||||
* Example:
|
||||
* <pre>
|
||||
* @Flogger
|
||||
* public class LogExample {
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* will generate:
|
||||
*
|
||||
* <pre>
|
||||
* public class LogExample {
|
||||
* private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* This annotation is valid for classes and enumerations.<br>
|
||||
* @see <a href="https://google.github.io/flogger/">com.google.common.flogger</a>
|
||||
* @see lombok.extern.apachecommons.CommonsLog @CommonsLog
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface Flogger {
|
||||
}
|
||||
Vendored
+1
@@ -55,6 +55,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+2
-1
@@ -53,8 +53,9 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.java.Log @Log
|
||||
* @see lombok.extern.log4j.Log4j @Log4j
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
* */
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+1
@@ -56,6 +56,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+1
@@ -56,6 +56,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.XSlf4j @XSlf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ import java.lang.annotation.Target;
|
||||
* @see lombok.extern.log4j.Log4j2 @Log4j2
|
||||
* @see lombok.extern.slf4j.Slf4j @Slf4j
|
||||
* @see lombok.extern.jbosslog.JBossLog @JBossLog
|
||||
* @see lombok.extern.flogger.Flogger @Flogger
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target(ElementType.TYPE)
|
||||
|
||||
@@ -91,16 +91,18 @@ public class HandleLog {
|
||||
// private static final <loggerType> log = <factoryMethod>(<parameter>);
|
||||
JCExpression loggerType = chainDotsString(typeNode, framework.getLoggerTypeName());
|
||||
JCExpression factoryMethod = chainDotsString(typeNode, framework.getLoggerFactoryMethodName());
|
||||
|
||||
|
||||
JCExpression loggerName;
|
||||
if (loggerTopic == null || loggerTopic.trim().length() == 0) {
|
||||
if (!framework.passTypeName) {
|
||||
loggerName = null;
|
||||
} else if (loggerTopic == null || loggerTopic.trim().length() == 0) {
|
||||
loggerName = framework.createFactoryParameter(typeNode, loggingType);
|
||||
} else {
|
||||
loggerName = maker.Literal(loggerTopic);
|
||||
}
|
||||
|
||||
JCMethodInvocation factoryMethodCall = maker.Apply(List.<JCExpression>nil(), factoryMethod, List.<JCExpression>of(loggerName));
|
||||
|
||||
|
||||
JCMethodInvocation factoryMethodCall = maker.Apply(List.<JCExpression>nil(), factoryMethod, loggerName != null ? List.<JCExpression>of(loggerName) : List.<JCExpression>nil());
|
||||
|
||||
JCVariableDecl fieldDecl = recursiveSetGeneratedBy(maker.VarDef(
|
||||
maker.Modifiers(Flags.PRIVATE | Flags.FINAL | (useStatic ? Flags.STATIC : 0)),
|
||||
typeNode.toName(logFieldName), loggerType, factoryMethodCall), source, typeNode.getContext());
|
||||
@@ -186,6 +188,17 @@ public class HandleLog {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link lombok.extern.flogger.Flogger} annotation for javac.
|
||||
*/
|
||||
@ProviderFor(JavacAnnotationHandler.class)
|
||||
public static class HandleFloggerLog extends JavacAnnotationHandler<lombok.extern.flogger.Flogger> {
|
||||
@Override public void handle(AnnotationValues<lombok.extern.flogger.Flogger> annotation, JCAnnotation ast, JavacNode annotationNode) {
|
||||
handleFlagUsage(annotationNode, ConfigurationKeys.LOG_FLOGGER_FLAG_USAGE, "@Flogger", ConfigurationKeys.LOG_ANY_FLAG_USAGE, "any @Log");
|
||||
processAnnotation(LoggingFramework.FLOGGER, annotation, annotationNode, "");
|
||||
}
|
||||
}
|
||||
|
||||
enum LoggingFramework {
|
||||
// private static final org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog(TargetType.class);
|
||||
COMMONS(lombok.extern.apachecommons.CommonsLog.class, "org.apache.commons.logging.Log", "org.apache.commons.logging.LogFactory.getLog"),
|
||||
@@ -212,17 +225,29 @@ public class HandleLog {
|
||||
XSLF4J(lombok.extern.slf4j.XSlf4j.class, "org.slf4j.ext.XLogger", "org.slf4j.ext.XLoggerFactory.getXLogger"),
|
||||
|
||||
// private static final org.jboss.logging.Logger log = org.jboss.logging.Logger.getLogger(TargetType.class);
|
||||
JBOSSLOG(lombok.extern.jbosslog.JBossLog.class, "org.jboss.logging.Logger", "org.jboss.logging.Logger.getLogger")
|
||||
JBOSSLOG(lombok.extern.jbosslog.JBossLog.class, "org.jboss.logging.Logger", "org.jboss.logging.Logger.getLogger"),
|
||||
|
||||
// private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
FLOGGER(lombok.extern.flogger.Flogger.class, "com.google.common.flogger.FluentLogger", "com.google.common.flogger.FluentLogger.forEnclosingClass", false),
|
||||
;
|
||||
|
||||
private final Class<? extends Annotation> annotationClass;
|
||||
private final String loggerTypeName;
|
||||
private final String loggerFactoryName;
|
||||
private final boolean passTypeName;
|
||||
|
||||
LoggingFramework(Class<? extends Annotation> annotationClass, String loggerTypeName, String loggerFactoryName, boolean passTypeName) {
|
||||
this.annotationClass = annotationClass;
|
||||
this.loggerTypeName = loggerTypeName;
|
||||
this.loggerFactoryName = loggerFactoryName;
|
||||
this.passTypeName = passTypeName;
|
||||
}
|
||||
|
||||
LoggingFramework(Class<? extends Annotation> annotationClass, String loggerTypeName, String loggerFactoryName) {
|
||||
this.annotationClass = annotationClass;
|
||||
this.loggerTypeName = loggerTypeName;
|
||||
this.loggerFactoryName = loggerFactoryName;
|
||||
this.passTypeName = true;
|
||||
}
|
||||
|
||||
final Class<? extends Annotation> getAnnotationClass() {
|
||||
|
||||
@@ -31,6 +31,7 @@ module lombok {
|
||||
exports lombok.extern.jbosslog;
|
||||
exports lombok.extern.log4j;
|
||||
exports lombok.extern.slf4j;
|
||||
exports lombok.extern.flogger;
|
||||
|
||||
provides javax.annotation.processing.Processor with lombok.launch.AnnotationProcessorHider.AnnotationProcessor;
|
||||
provides org.mapstruct.ap.spi.AstModifyingAnnotationProcessor with lombok.launch.AnnotationProcessorHider.AstModificationNotifier;
|
||||
|
||||
@@ -146,6 +146,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
|
||||
classpath.add("lib/test/org.jboss.logging-jboss-logging.jar");
|
||||
classpath.add("lib/test/com.google.guava-guava.jar");
|
||||
classpath.add("lib/test/com.google.code.findbugs-findbugs.jar");
|
||||
classpath.add("lib/test/com.google.flogger-flogger.jar");
|
||||
return new FileSystem(classpath.toArray(new String[0]), new String[] {file.getAbsolutePath()}, "UTF-8");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class LoggerFlogger {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
}
|
||||
class LoggerFloggerWithImport {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
}
|
||||
class LoggerFloggerOuter {
|
||||
static class Inner {
|
||||
@java.lang.SuppressWarnings("all")
|
||||
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
import lombok.extern.flogger.Flogger;
|
||||
@lombok.extern.flogger.Flogger class LoggerFlogger {
|
||||
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
<clinit>() {
|
||||
}
|
||||
LoggerFlogger() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@Flogger class LoggerFloggerWithImport {
|
||||
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
<clinit>() {
|
||||
}
|
||||
LoggerFloggerWithImport() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
class LoggerFloggerOuter {
|
||||
static @lombok.extern.flogger.Flogger class Inner {
|
||||
private static final com.google.common.flogger.FluentLogger log = com.google.common.flogger.FluentLogger.forEnclosingClass();
|
||||
<clinit>() {
|
||||
}
|
||||
Inner() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
LoggerFloggerOuter() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import lombok.extern.flogger.Flogger;
|
||||
|
||||
@lombok.extern.flogger.Flogger
|
||||
class LoggerFlogger {
|
||||
}
|
||||
|
||||
@Flogger
|
||||
class LoggerFloggerWithImport {
|
||||
}
|
||||
|
||||
class LoggerFloggerOuter {
|
||||
@lombok.extern.flogger.Flogger
|
||||
static class Inner {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,8 @@
|
||||
The various <code>@Log</code> variants were added in lombok v0.10.
|
||||
<em>NEW in lombok 0.10: </em>You can annotate any class with a log annotation to let lombok generate a logger field.<br/>
|
||||
The logger is named <code>log</code> and the field's type depends on which logger you have selected.
|
||||
</p><p>
|
||||
<em>NEW in lombok v1.16.24: </em>Addition of google's FluentLogger (flogger).
|
||||
</p>
|
||||
</@f.history>
|
||||
|
||||
@@ -19,14 +21,18 @@
|
||||
<code>@CommonsLog</code>
|
||||
</dt><dd>
|
||||
Creates <code><span class="keyword">private static final </span><a href="https://commons.apache.org/logging/apidocs/org/apache/commons/logging/Log.html">org.apache.commons.logging.Log</a> <span class="staticfield">log</span> = <a href="https://commons.apache.org/logging/apidocs/org/apache/commons/logging/LogFactory.html#getLog(java.lang.Class)">org.apache.commons.logging.LogFactory.getLog</a>(LogExample.<span class="keyword">class</span>);</code>
|
||||
</dd><dt>
|
||||
<code>@Flogger</code>
|
||||
</dt><dd>
|
||||
Creates <code><span class="keyword">private static final </span><a href="https://google.github.io/flogger/">com.google.common.flogger.FluentLogger</a> <span class="staticfield">log</span> = com.google.common.flogger.FluentLogger.forEnclosingClass();</code>
|
||||
</dd><dt>
|
||||
<code>@JBossLog</code>
|
||||
</dt><dd>
|
||||
Creates <code><span class="keyword">private static final </span><a href="http://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html">org.jboss.logging.Logger</a> <span class="staticfield">log</span> = <a href="http://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html#getLogger(java.lang.Class)">org.jboss.logging.Logger.getLogger</a>(LogExample.<span class="keyword">class</span>);</code>
|
||||
Creates <code><span class="keyword">private static final </span><a href="https://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html">org.jboss.logging.Logger</a> <span class="staticfield">log</span> = <a href="https://docs.jboss.org/jbosslogging/latest/org/jboss/logging/Logger.html#getLogger(java.lang.Class)">org.jboss.logging.Logger.getLogger</a>(LogExample.<span class="keyword">class</span>);</code>
|
||||
</dd><dt>
|
||||
<code>@Log</code>
|
||||
</dt><dd>
|
||||
Creates <code><span class="keyword">private static final </span><a href="http://download.oracle.com/javase/6/docs/api/java/util/logging/Logger.html">java.util.logging.Logger</a> <span class="staticfield">log</span> = <a href="http://download.oracle.com/javase/6/docs/api/java/util/logging/Logger.html#getLogger(java.lang.String)">java.util.logging.Logger.getLogger</a>(LogExample.<span class="keyword">class</span>.getName());</code>
|
||||
Creates <code><span class="keyword">private static final </span><a href="https://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html">java.util.logging.Logger</a> <span class="staticfield">log</span> = <a href="https://docs.oracle.com/javase/6/docs/api/java/util/logging/Logger.html#getLogger(java.lang.String)">java.util.logging.Logger.getLogger</a>(LogExample.<span class="keyword">class</span>.getName());</code>
|
||||
</dd><dt>
|
||||
<code>@Log4j</code>
|
||||
</dt><dd>
|
||||
@@ -38,11 +44,11 @@
|
||||
</dd><dt>
|
||||
<code>@Slf4j</code>
|
||||
</dt><dd>
|
||||
Creates <code><span class="keyword">private static final </span><a href="http://www.slf4j.org/api/org/slf4j/Logger.html">org.slf4j.Logger</a> <span class="staticfield">log</span> = <a href="http://www.slf4j.org/apidocs/org/slf4j/LoggerFactory.html#getLogger(java.lang.Class)">org.slf4j.LoggerFactory.getLogger</a>(LogExample.<span class="keyword">class</span>);</code>
|
||||
Creates <code><span class="keyword">private static final </span><a href="https://www.slf4j.org/api/org/slf4j/Logger.html">org.slf4j.Logger</a> <span class="staticfield">log</span> = <a href="https://www.slf4j.org/api/org/slf4j/LoggerFactory.html#getLogger(java.lang.Class)">org.slf4j.LoggerFactory.getLogger</a>(LogExample.<span class="keyword">class</span>);</code>
|
||||
</dd><dt>
|
||||
<code>@XSlf4j</code>
|
||||
</dt><dd>
|
||||
Creates <code><span class="keyword">private static final </span><a href="http://www.slf4j.org/api/org/slf4j/ext/XLogger.html">org.slf4j.ext.XLogger</a> <span class="staticfield">log</span> = <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>
|
||||
Creates <code><span class="keyword">private static final </span><a href="https://www.slf4j.org/api/org/slf4j/ext/XLogger.html">org.slf4j.ext.XLogger</a> <span class="staticfield">log</span> = <a href="https://www.slf4j.org/api/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>
|
||||
@@ -70,13 +76,17 @@
|
||||
</dt><dd>
|
||||
Lombok will flag any usage of <code>@lombok.extern.apachecommons.CommonsLog</code> as a warning or error if configured.
|
||||
</dd><dt>
|
||||
<code>lombok.log.javaUtilLogging.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
<code>lombok.log.flogger.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
</dt><dd>
|
||||
Lombok will flag any usage of <code>@lombok.extern.java.Log</code> as a warning or error if configured.
|
||||
Lombok will flag any usage of <code>@lombok.extern.flogger.Flogger</code> as a warning or error if configured.
|
||||
</dd><dt>
|
||||
<code>lombok.log.jbosslog.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
</dt><dd>
|
||||
Lombok will flag any usage of <code>@lombok.extern.jbosslog.JBossLog</code> as a warning or error if configured.
|
||||
</dd><dt>
|
||||
<code>lombok.log.javaUtilLogging.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
</dt><dd>
|
||||
Lombok will flag any usage of <code>@lombok.extern.java.Log</code> as a warning or error if configured.
|
||||
</dd><dt>
|
||||
<code>lombok.log.log4j.flagUsage</code> = [<code>warning</code> | <code>error</code>] (default: not set)
|
||||
</dt><dd>
|
||||
|
||||
Reference in new issue
Block a user