You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2019/11/11 13:45:00 UTC

[sling-org-apache-sling-connection-timeout-agent] branch feature/SLING-8837 created (now 4a83b89)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to branch feature/SLING-8837
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-connection-timeout-agent.git.


      at 4a83b89  SLING-8837 - Add extra verbose mode to startup options

This branch includes the following new commits:

     new 4a83b89  SLING-8837 - Add extra verbose mode to startup options

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-connection-timeout-agent] 01/01: SLING-8837 - Add extra verbose mode to startup options

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to branch feature/SLING-8837
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-connection-timeout-agent.git

commit 4a83b8978a106598cb77c6f36e4d54cfdd41a59d
Author: Robert Munteanu <ro...@apache.org>
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) {