jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1855126 - /jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
Date Sat, 09 Mar 2019 16:35:46 GMT
Author: pmouawad
Date: Sat Mar  9 16:35:46 2019
New Revision: 1855126

URL: http://svn.apache.org/viewvc?rev=1855126&view=rev
Log:
Fix logging

Modified:
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java?rev=1855126&r1=1855125&r2=1855126&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/sampler/JavaSampler.java
Sat Mar  9 16:35:46 2019
@@ -123,9 +123,9 @@ public class JavaSampler extends Abstrac
             javaClass = Class.forName(name, false, Thread.currentThread().getContextClassLoader());
             Method method = javaClass.getMethod("teardownTest", JavaSamplerContext.class);
             isToBeRegistered = !method.getDeclaringClass().equals(AbstractJavaSamplerClient.class);
-            log.info("Created class: " + name + ". Uses tearDownTest: " + isToBeRegistered);
+            log.info("Created class: {}. Uses tearDownTest: ", name, isToBeRegistered);
         } catch (Exception e) {
-            log.error(whoAmI() + "\tException initialising: " + name, e);
+            log.error("{}\tException initialising: ", whoAmI(), name, e);
         }
         
     }
@@ -189,7 +189,9 @@ public class JavaSampler extends Abstrac
                                                         // to test element name
         context = new JavaSamplerContext(args);
         if (javaClient == null) {
-            log.debug(whoAmI() + "\tCreating Java Client");
+            if (log.isDebugEnabled()) {
+                log.debug("{}\tCreating Java Client", whoAmI());
+            }
             javaClient = createJavaClient();
             javaClient.setupTest(context);
         }
@@ -222,15 +224,16 @@ public class JavaSampler extends Abstrac
             client = (JavaSamplerClient) javaClass.getDeclaredConstructor().newInstance();
 
             if (log.isDebugEnabled()) {
-                log.debug(whoAmI() + "\tCreated:\t" + getClassname() + "@"
-                        + Integer.toHexString(client.hashCode()));
+                log.debug("{}\tCreated:\t{}@{}", whoAmI(), getClassname(), Integer.toHexString(client.hashCode()));
             }
             
             if(isToBeRegistered) {
                 TEAR_DOWN_SET.add(this);
             }
         } catch (Exception e) {
-            log.error(whoAmI() + "\tException creating: " + getClassname(), e);
+            if (log.isErrorEnabled()) { 
+                log.error("{}\tException creating: {}", whoAmI(), getClassname(), e);
+            }
             client = new ErrorSamplerClient();
         }
         return client;
@@ -265,14 +268,18 @@ public class JavaSampler extends Abstrac
     /* Implements TestStateListener.testStarted() */
     @Override
     public void testStarted() {
-        log.debug(whoAmI() + "\ttestStarted");
+        if (log.isDebugEnabled()) {
+            log.debug("{}\ttestStarted", whoAmI());
+        }
         initClass();
     }
 
     /* Implements TestStateListener.testStarted(String) */
     @Override
     public void testStarted(String host) {
-        log.debug(whoAmI() + "\ttestStarted(" + host + ")");
+        if (log.isDebugEnabled()) {
+            log.debug("{}\ttestStarted({})", whoAmI(), host);
+        }
         initClass();
     }
 
@@ -285,7 +292,9 @@ public class JavaSampler extends Abstrac
      */
     @Override
     public void testEnded() {
-        log.debug(whoAmI() + "\ttestEnded");
+        if (log.isDebugEnabled()) {
+            log.debug("{}\ttestEnded", whoAmI());
+        }
         synchronized (TEAR_DOWN_SET) {
             for (JavaSampler javaSampler : TEAR_DOWN_SET) {
                 JavaSamplerClient client = javaSampler.javaClient;
@@ -318,7 +327,9 @@ public class JavaSampler extends Abstrac
          */
         @Override
         public SampleResult runTest(JavaSamplerContext p_context) {
-            log.debug(whoAmI() + "\trunTest");
+            if (log.isDebugEnabled()) {
+                log.debug("{}\trunTest", whoAmI());
+            }
             Thread.yield();
             SampleResult results = new SampleResult();
             results.setSuccessful(false);



Mime
View raw message