This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-connection-timeout-agent.git
The following commit(s) were added to refs/heads/master by this push:
new fa76732 SLING-8837 - Add extra verbose mode to startup options
fa76732 is described below
commit fa76732d332287a8d3b8001fb519ca0bc47a6a04
Author: Robert Munteanu <[email protected]>
AuthorDate: Mon Nov 11 14:44:47 2019 +0100
SLING-8837 - Add extra verbose mode to startup options
---
src/main/java/org/apache/sling/cta/impl/Log.java | 27 +++++++++++++++++++++-
.../cta/impl/MBeanAwareTimeoutTransformer.java | 4 ++++
2 files changed, 30 insertions(+), 1 deletion(-)
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 @@ abstract class Log {
* @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 @@ abstract class Log {
*/
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 @@ abstract class Log {
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 @@ abstract class Log {
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 @@ public abstract class MBeanAwareTimeoutTransformer implements
ClassFileTransform
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 @@ public abstract class MBeanAwareTimeoutTransformer implements
ClassFileTransform
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) {