SLING-8837 - Add extra verbose mode to startup options
diff --git a/src/main/java/org/apache/sling/cta/impl/Log.java b/src/main/java/org/apache/sling/cta/impl/Log.java
index 0b7f4e3..8826461 100644
--- a/src/main/java/org/apache/sling/cta/impl/Log.java
+++ b/src/main/java/org/apache/sling/cta/impl/Log.java
@@ -40,7 +40,11 @@
* @param spec the logger spec, <tt>v</tt> for a console log, anything else for a no-op log
*/
public static void configure(String spec) {
- INSTANCE = "v".equals(spec) ? new ConsoleLog() : new NoopLog();
+
+ boolean isVerbose = "v".equals(spec);
+ boolean isExtraVerbose = "vv".equals(spec);
+
+ INSTANCE = isVerbose || isExtraVerbose ? new ConsoleLog(isExtraVerbose) : new NoopLog();
}
/**
@@ -73,6 +77,8 @@
*/
public abstract void log(String msg, Object... args);
+ public abstract void trace(String msg, Object... args);
+
/**
* Prints the throwable stack trace and throws a <tt>RuntimeException</tt>
*
@@ -85,12 +91,26 @@
private static final String LOG_ENTRY_PREFIX = "[AGENT] ";
+ private final boolean trace;
+
+ ConsoleLog(boolean trace) {
+ this.trace = trace;
+ }
+
@Override
public void log(String msg, Object... args) {
System.out.format(LOG_ENTRY_PREFIX + msg + " %n", args); // NOSONAR - this is a logger, OK to use System.out
}
@Override
+ public void trace(String msg, Object... args) {
+ if ( !trace )
+ return;
+
+ log(msg, args);
+ }
+
+ @Override
public void fatal(String msg, Throwable t) {
// ensure _something_ is printed, throwable might not be printed
t.printStackTrace(); // NOSONAR - OK to use printStackTrace, we are a logger
@@ -110,5 +130,10 @@
public void fatal(String message, Throwable t) {
// empty by design
}
+
+ @Override
+ public void trace(String msg, Object... args) {
+ // empty by design
+ }
}
}
diff --git a/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java b/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java
index d3118f0..de3f62d 100644
--- a/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java
+++ b/src/main/java/org/apache/sling/cta/impl/MBeanAwareTimeoutTransformer.java
@@ -41,6 +41,8 @@
this.agentInfo = agent;
this.classesToTransform = classesToTransform;
this.agentInfo.registerTransformer(getClass());
+
+ Log.get().log("%s configured to transform the following classes: %s", getClass().getSimpleName(), this.classesToTransform);
}
@Override
@@ -60,6 +62,8 @@
classfileBuffer = doTransformClass(cc);
Log.get().log("Transformation of %s complete", className);
this.agentInfo.registerTransformedClass(className);
+ } else {
+ Log.get().trace("%s did not transform %s as it was not part of the classes it handles", getClass().getSimpleName(), className);
}
return classfileBuffer;
} catch (Exception e) {