Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2015-08-05 18:19:00 +0000
committerslewis2015-08-05 18:19:00 +0000
commit83940fecc915108c7c54590dbd3cb97451499746 (patch)
tree14f5290aade9fa2f44815dbd70719aa77f598dba
parent009010a251d698b98bb019fceb32d2493a0acdaf (diff)
downloadorg.eclipse.ecf-83940fecc915108c7c54590dbd3cb97451499746.tar.gz
org.eclipse.ecf-83940fecc915108c7c54590dbd3cb97451499746.tar.xz
org.eclipse.ecf-83940fecc915108c7c54590dbd3cb97451499746.zip
Allows use of 'logservice' | 'true or 'systemout' | 'false' for the
ch.ethz.iks.r_osgi.traceSendMessageTime system property. Change-Id: I81d436b12fc75a5ca47359dde6a13c6402d4d525
-rw-r--r--protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java33
1 files changed, 27 insertions, 6 deletions
diff --git a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java
index a5ff32aa7..4dabc7697 100644
--- a/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java
+++ b/protocols/bundles/ch.ethz.iks.r_osgi.remote/src/main/java/ch/ethz/iks/r_osgi/impl/ChannelEndpointImpl.java
@@ -35,8 +35,10 @@ import java.io.NotSerializableException;
import java.io.OutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Date;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.HashSet;
@@ -983,16 +985,32 @@ public final class ChannelEndpointImpl implements ChannelEndpoint {
private long startTime;
- public static final boolean TRACE_TIME = new Boolean(System.getProperty("ch.ethz.iks.r_osgi.traceSendMessageTime","false")).booleanValue();
+ public static final String TRACE_TIME_PROP = System.getProperty("ch.ethz.iks.r_osgi.traceSendMessageTime");
+
+ private static boolean TRACE_TIME = false;
+ private static boolean USE_LOG_SERVICE = true;
+
+ static {
+ if (TRACE_TIME_PROP != null) {
+ if (TRACE_TIME_PROP.equalsIgnoreCase("logservice") || TRACE_TIME_PROP.equalsIgnoreCase("true")) {
+ TRACE_TIME = true;
+ } else if (TRACE_TIME_PROP.equalsIgnoreCase("systemout")) {
+ TRACE_TIME = true;
+ USE_LOG_SERVICE = false;
+ }
+ }
+ }
+
+ private static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.SSSZ");
void startTiming(String message) {
if (TRACE_TIME) {
startTime = System.currentTimeMillis();
StringBuffer buf = new StringBuffer("TIMING.START;");
+ buf.append(sdf.format(new Date(startTime))).append(";");
buf.append((message==null?"":message));
- buf.append(";startTime=").append(startTime);
LogService logService = RemoteOSGiServiceImpl.log;
- if (logService != null)
+ if (logService != null && USE_LOG_SERVICE)
logService.log(LogService.LOG_INFO, buf.toString());
else
System.out.println(buf.toString());
@@ -1002,10 +1020,11 @@ public final class ChannelEndpointImpl implements ChannelEndpoint {
void stopTiming(String message, Throwable exception) {
if (TRACE_TIME) {
StringBuffer buf = new StringBuffer("TIMING.END;");
+ buf.append(sdf.format(new Date(startTime))).append(";");
buf.append((message==null?"":message));
buf.append(";duration(ms)=").append((System.currentTimeMillis()-startTime));
LogService logService = RemoteOSGiServiceImpl.log;
- if (logService != null) {
+ if (logService != null && USE_LOG_SERVICE) {
if (exception != null)
logService.log(LogService.LOG_ERROR, buf.toString(), exception);
else
@@ -1015,6 +1034,7 @@ public final class ChannelEndpointImpl implements ChannelEndpoint {
if (exception != null)
exception.printStackTrace();
}
+ startTime = 0;
}
}
@@ -1034,7 +1054,8 @@ public final class ChannelEndpointImpl implements ChannelEndpoint {
}
Throwable t = null;
- startTiming("sendMessage");
+ String timingMsg = "sendMessage;funcId="+msg.getFuncID()+";xid="+msg.getXID();
+ startTiming(timingMsg);
try {
try {
@@ -1062,7 +1083,7 @@ public final class ChannelEndpointImpl implements ChannelEndpoint {
t = new RemoteOSGiException("Network error", ioe); //$NON-NLS-1$
throw ((RemoteOSGiException) t);
} finally {
- stopTiming("sendMessage",t);
+ stopTiming(timingMsg,t);
}
}

Back to the top