Top Description Inners Methods
groovy.util.logging

public @Interface Log4j

extends Annotation
Annotations
@Documented
@Retention:SOURCE
@Target:TYPE
@GroovyASTTransformationClass:LogASTTransformation
Imports
groovy.lang.GroovyClassLoader, groovy.transform.Undefined, org.codehaus.groovy.ast.ClassNode, .FieldNode, org.codehaus.groovy.ast.expr.ArgumentListExpression, .AttributeExpression, .ClassExpression, .ConstantExpression, .Expression, .MethodCallExpression, org.codehaus.groovy.transform.GroovyASTTransformationClass, .LogASTTransformation, java.lang.annotation.ElementType, .Retention, .RetentionPolicy, .Target, java.util.Locale

This local transform adds a logging ability to your program using Log4j logging. Every method call on a unbound variable named log will be mapped to a call to the logger. For this a log field will be inserted in the class. If the field already exists the usage of this transform will cause a compilation error. The method name will be used to determine what to call on the logger.
log.name(exp)
is mapped to
if (log.isNameEnabled() {
   log.name(exp)
}
Here name is a place holder for info, debug, warning, error, etc. If the expression exp is a constant or only a variable access the method call will not be transformed. But this will still cause a call on the injected logger.
Since
1.8.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Method Summary

Modifier and TypeMethod and Description
public String
public Class<? extends LogASTTransformation.LoggingStrategy>
public String
public String
visibilityId()

If specified, must match the "id" attribute in a VisibilityOptions annotation to enable a custom visibility.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

categoryback to summary
public String category()
loggingStrategyback to summary
public Class<? extends LogASTTransformation.LoggingStrategy> loggingStrategy()
valueback to summary
public String value()
visibilityIdback to summary
public String visibilityId()

If specified, must match the "id" attribute in a VisibilityOptions annotation to enable a custom visibility.

Since
3.0.0
groovy.util.logging back to summary

public Class Log4j.Log4jLoggingStrategy

extends AbstractLoggingStrategyV2
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final String
private static final String

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public FieldNode
addLoggerFieldToClass(ClassNode
the class that was originally annotated with the Log transformation.
classNode
,
String
the name of the logger field
logFieldName
,
String
the name of the logging category
categoryName
,
int
the modifiers (private, final, et. al.) of the logger field
fieldModifiers
)

Implements org.codehaus.groovy.transform.LogASTTransformation.LoggingStrategyV2.addLoggerFieldToClass.

In this method, you are given a ClassNode, a field name and a category name, and you must add a new Field onto the class.
public boolean
public Expression
Inherited from org.codehaus.groovy.transform.LogASTTransformation.AbstractLoggingStrategyV2:
addLoggerFieldToClass

Field Detail

LOGGER_NAMEback to summary
private static final String LOGGER_NAME
PRIORITY_NAMEback to summary
private static final String PRIORITY_NAME

Constructor Detail

Log4jLoggingStrategyback to summary
protected Log4jLoggingStrategy(final GroovyClassLoader loader)

Method Detail

addLoggerFieldToClassback to summary
public FieldNode addLoggerFieldToClass(ClassNode classNode, String logFieldName, String categoryName, int fieldModifiers)

Implements org.codehaus.groovy.transform.LogASTTransformation.LoggingStrategyV2.addLoggerFieldToClass.

Doc from org.codehaus.groovy.transform.LogASTTransformation.LoggingStrategyV2.addLoggerFieldToClass.

In this method, you are given a ClassNode, a field name and a category name, and you must add a new Field onto the class. Return the result of the ClassNode.addField operations.

Parameters
classNode:ClassNode

the class that was originally annotated with the Log transformation.

logFieldName:String

the name of the logger field

categoryName:String

the name of the logging category

fieldModifiers:int

the modifiers (private, final, et. al.) of the logger field

Returns:FieldNode

the FieldNode instance that was created and added to the class

Annotations
@Override
isLoggingMethodback to summary
public boolean isLoggingMethod(String methodName)

Implements org.codehaus.groovy.transform.LogASTTransformation.LoggingStrategy.isLoggingMethod.

Annotations
@Override
wrapLoggingMethodCallback to summary
public Expression wrapLoggingMethodCall(Expression logVariable, String methodName, Expression originalExpression)

Implements org.codehaus.groovy.transform.LogASTTransformation.LoggingStrategy.wrapLoggingMethodCall.

Annotations
@Override