Skip to content

Commit

Permalink
Add more debug logs to COM API calls (#120)
Browse files Browse the repository at this point in the history
Add more debug logs to COM API calls
  • Loading branch information
JanGu-TT authored Dec 4, 2019
1 parent 1b658da commit 88ea7a5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -556,6 +557,20 @@ node('windows') {
```
</details>

## 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).
Expand Down
Binary file added docs/images/create_new_debug_log_recorder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

/**
Expand All @@ -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);
Expand Down

0 comments on commit 88ea7a5

Please sign in to comment.