public interface LogASTTransformation.LoggingStrategy
A LoggingStrategy defines how to wire a new logger instance into an existing class. It is meant to be used with the
| Type Params | Return Type | Name and description |
|---|---|---|
|
public FieldNode |
addLoggerFieldToClass(ClassNode classNode, String fieldName, String categoryName)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 String |
getCategoryName(ClassNode classNode, String categoryName) |
|
public boolean |
isLoggingMethod(String methodName) |
|
public String |
staticLocationUnsupportedReason()Why wrapLoggingMethodCallWithLocation cannot be used with this strategy in the current compilation, for the compile error reported when staticLocation is requested anyway. |
|
public Expression |
wrapLoggingMethodCall(Expression logVariable, String methodName, Expression originalExpression) |
|
public Expression |
wrapLoggingMethodCallWithLocation(Expression logVariable, String methodName, MethodCallExpression originalCall, Expression location, boolean guard)Rewrites a logging call so that the logging framework is handed the statement's location, computed at compile time, instead of walking the stack at run time (GROOVY-12378). |
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.
classNode - the class that was originally annotated with the Log transformation.fieldName - the name of the logger fieldcategoryName - the name of the logging category Why wrapLoggingMethodCallWithLocation cannot be used with this
strategy in the current compilation, for the compile error reported when
staticLocation is requested anyway. A strategy whose logging API
accepts a caller-supplied location returns null when that API is
resolvable, and names what is missing from the compile classpath when it
is not. By default compile-time locations are not implemented.
null if they are supported Rewrites a logging call so that the logging framework is handed the
statement's location, computed at compile time, instead of walking the
stack at run time (GROOVY-12378). Only called when
staticLocationUnsupportedReason() returned null.
logVariable - the logger expressionmethodName - the logging method that was called, e.g. infooriginalCall - the call as written; its arguments are the call's argumentslocation - an expression yielding the StackTraceElement for the statementguard - whether the arguments are worth guarding with a level check
(they are not all constants or variables)null to leave the call unchanged