Top Description Inners Methods
groovy.util.logging

public @Interface Log

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

This local transform adds a logging ability to your program using java.util.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.isLoggable(Level.NAME) {
   log.name(exp)
}
Here name is a place holder for info, fine, finer, finest, config, warning, severe. NAME is name transformed to upper case. if anything else is used it will result in an exception at runtime. 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
Log.JavaUtilLoggingStrategy

This class contains the logic of how to weave a Java Util Logging logger into the host 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 Log.JavaUtilLoggingStrategy

extends AbstractLoggingStrategyV2
Class Inheritance

This class contains the logic of how to weave a Java Util Logging logger into the host class.

Field Summary

Modifier and TypeField and Description
private static final ClassNode
private static final ClassNode

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

LEVEL_CLASSNODEback to summary
private static final ClassNode LEVEL_CLASSNODE
LOGGER_CLASSNODEback to summary
private static final ClassNode LOGGER_CLASSNODE

Constructor Detail

JavaUtilLoggingStrategyback to summary
protected JavaUtilLoggingStrategy(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