ppkarwasz commented on PR #1147:
URL: https://github.com/apache/logging-log4j2/pull/1147#issuecomment-1328638581
@rgoers,
The effect on debugging transformed code is similar to what happens with
AspectJ or other weaving tools. If you enter multiple times into an
`info(Marker, String, Throwable)` call, the debugger will transport you in
sequence to `atInfo()`, `withLocation()`, `withMarker()`, `withThrowable()`,
`log(String)`. Personally I don't find it more _strange_ than debugging a
concatenation of strings, which redirects you to some method calls on
`StringBuilder`.
That said, later on I can add a Javac plugin that generates the source code
of the location cache, which resembles:
```
class MainClass$$Log4j$$Cache {
StackTraceElement[] locations = {
new StackTraceElement("org.example.MainClass", "method"
"MainClass.java", 42),
...
};
}
```
As for the modified source code of the original class, I would rather use
some source code refactoring tool (Carter suggested Error Prone) that would
transform:
```
logger.info(MY_MARKER, "Hello world", e);
```
into
```
logger.atInfo().withMarker(MY_MARKER).withThrowable(e).log("Hello world");
```
After this transformation, we still need bytecode weaving, but the
transformation consists in a trivial `withLocation()` call just after
`atInfo()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]