diff --git a/README.md b/README.md index c59cf2b3..30b91b48 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ It supports standardized access to a broad range of test tools and provides auto - [Extensions](#extensions) - [Job DSL](#job-dsl) - [Pipeline](#pipeline) +- [Debugging](#debugging) - [Issues](#issues) - [Known limitations](#known-limitations) - [FAQ](#faq) @@ -556,6 +557,20 @@ node('windows') { ``` +## Debugging + +To change the job console log level to debug, the system property `ecutest.debugLog` should be set to `true`. This could be done either at startup + +`java -Decutest.debugLog=true -jar jenkins.war` + +or at runtime in the console under `Jenkins -> Manage Jenkins -> Script Console` + +`System.setProperty("ecutest.debugLog", "true")` + +To get a more debug output about plugin COM API communication a new log recorder with following logger instances could be created under `Manage Jenkins -> System Log -> New Log Recorder`. Set a preferable name, add loggers `de.tracetronic.jenkins.plugins.ecutest.wrapper.com.ETComClient`, `de.tracetronic.jenkins.plugins.ecutest.wrapper.com.ETComDispatch` and set the log level to at least `FINE`. + +![Create new COM API log recorder](docs/images/create_new_debug_log_recorder.png "Create new COM API log recorder") + ## Issues To report a bug or request an enhancement to this plugin please raise a new [GitHub issue](https://github.com/jenkinsci/ecutest-plugin/issues/new) or create a [ticket in JIRA](https://issues.jenkins-ci.org/secure/CreateIssueDetails!init.jspa?pid=10172&components=20856&issuetype=1&priority=4). diff --git a/docs/images/create_new_debug_log_recorder.png b/docs/images/create_new_debug_log_recorder.png new file mode 100644 index 00000000..24acc3d5 Binary files /dev/null and b/docs/images/create_new_debug_log_recorder.png differ diff --git a/src/main/java/de/tracetronic/jenkins/plugins/ecutest/wrapper/com/ETComDispatch.java b/src/main/java/de/tracetronic/jenkins/plugins/ecutest/wrapper/com/ETComDispatch.java index 9232cba8..0f960622 100644 --- a/src/main/java/de/tracetronic/jenkins/plugins/ecutest/wrapper/com/ETComDispatch.java +++ b/src/main/java/de/tracetronic/jenkins/plugins/ecutest/wrapper/com/ETComDispatch.java @@ -9,6 +9,7 @@ import com.jacob.com.Dispatch; import com.jacob.com.JacobException; import com.jacob.com.Variant; +import org.apache.commons.lang.StringUtils; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; @@ -17,6 +18,7 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import java.util.logging.Logger; /** * Custom dispatch to perform requests on application specific COM API. @@ -28,6 +30,7 @@ public class ETComDispatch extends Dispatch implements AutoCloseable { private static final Object[] NO_PARAMS = new Object[0]; + private static final Logger LOGGER = Logger.getLogger(ETComDispatch.class.getName()); private final boolean useTimeout; @@ -163,7 +166,11 @@ protected Variant performDirectRequest(final String method, final Object... para */ private Variant callDispatch(final String method, final Object... params) throws ETComException { try { - return Dispatch.call(this, method, params); + String parameters = StringUtils.join(params, ','); + Variant result = Dispatch.call(this, method, params); + String dispatchName = this.getClass().getSimpleName(); + LOGGER.fine(String.format("%s.call(): %s (%s) --> %s", dispatchName, method, parameters, result)); + return result; } catch (final JacobException e) { throw new ETComException(e.getMessage(), e); } catch (final Throwable t) { @@ -173,7 +180,10 @@ private Variant callDispatch(final String method, final Object... params) throws @Override public boolean isAttached() { - return super.isAttached(); + final boolean isAttached = super.isAttached(); + String dispatchName = this.getClass().getSimpleName(); + LOGGER.finer(String.format("%s.isAttached() --> %s", dispatchName, isAttached)); + return isAttached; } /** @@ -183,6 +193,8 @@ public boolean isAttached() { */ private void releaseDispatch() throws ETComException { try { + String dispatchName = this.getClass().getSimpleName(); + LOGGER.finer(String.format("%s.safeRelease()", dispatchName)); safeRelease(); } catch (final JacobException e) { throw new ETComException(e.getMessage(), e);