create AgentBuilder instance with logging listeners only if debug mode is enabled

This commit is contained in:
heathkd 2020-02-19 15:42:40 -05:00
parent e4a454549d
commit b7b46caaa8
1 changed files with 8 additions and 2 deletions

View File

@ -58,10 +58,8 @@ public class AgentInstaller {
new AgentBuilder.Default()
.disableClassFormatChanges()
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
.with(new RedefinitionLoggingListener())
.with(AgentBuilder.DescriptionStrategy.Default.POOL_ONLY)
.with(AgentTooling.poolStrategy())
.with(new TransformLoggingListener())
.with(new ClassLoadListener())
.with(AgentTooling.locationStrategy())
// FIXME: we cannot enable it yet due to BB/JVM bug, see
@ -139,6 +137,14 @@ public class AgentInstaller {
.or(isAnnotatedWith(named("javax.decorator.Decorator")))
.or(matchesConfiguredExcludes());
if (log.isDebugEnabled()) {
agentBuilder =
agentBuilder
.with(AgentBuilder.RedefinitionStrategy.RETRANSFORMATION)
.with(new RedefinitionLoggingListener())
.with(new TransformLoggingListener());
}
for (final AgentBuilder.Listener listener : listeners) {
agentBuilder = agentBuilder.with(listener);
}