1 package org
.eclipse
.linuxtools
.tmf
.ui
;
3 import java
.io
.BufferedWriter
;
4 import java
.io
.FileWriter
;
5 import java
.io
.IOException
;
7 import org
.eclipse
.core
.runtime
.Platform
;
9 @SuppressWarnings("nls")
10 public class TmfUiTracer
{
12 private static String pluginID
= TmfUiPlugin
.PLUGIN_ID
;
14 static Boolean ERROR
= Boolean
.FALSE
;
15 static Boolean WARNING
= Boolean
.FALSE
;
16 static Boolean INFO
= Boolean
.FALSE
;
18 static Boolean INDEX
= Boolean
.FALSE
;
19 static Boolean DISPLAY
= Boolean
.FALSE
;
20 static Boolean SORTING
= Boolean
.FALSE
;
22 private static String LOGNAME
= "traceUI.log";
23 private static BufferedWriter fTraceLog
= null;
25 private static BufferedWriter
openLogFile(String filename
) {
26 BufferedWriter outfile
= null;
28 outfile
= new BufferedWriter(new FileWriter(filename
));
29 } catch (IOException e
) {
35 public static void init() {
38 boolean isTracing
= false;
40 traceKey
= Platform
.getDebugOption(pluginID
+ "/error");
41 if (traceKey
!= null) {
42 ERROR
= (Boolean
.valueOf(traceKey
)).booleanValue();
46 traceKey
= Platform
.getDebugOption(pluginID
+ "/warning");
47 if (traceKey
!= null) {
48 WARNING
= (Boolean
.valueOf(traceKey
)).booleanValue();
52 traceKey
= Platform
.getDebugOption(pluginID
+ "/info");
53 if (traceKey
!= null) {
54 INFO
= (Boolean
.valueOf(traceKey
)).booleanValue();
58 traceKey
= Platform
.getDebugOption(pluginID
+ "/updateindex");
59 if (traceKey
!= null) {
60 INDEX
= (Boolean
.valueOf(traceKey
)).booleanValue();
64 traceKey
= Platform
.getDebugOption(pluginID
+ "/display");
65 if (traceKey
!= null) {
66 DISPLAY
= (Boolean
.valueOf(traceKey
)).booleanValue();
70 traceKey
= Platform
.getDebugOption(pluginID
+ "/sorting");
71 if (traceKey
!= null) {
72 SORTING
= (Boolean
.valueOf(traceKey
)).booleanValue();
76 // Create trace log file if needed
78 fTraceLog
= openLogFile(LOGNAME
);
82 public static void stop() {
83 if (fTraceLog
== null)
89 } catch (IOException e
) {
95 public static boolean isErrorTraced() {
99 public static boolean isIndexTraced() {
103 public static boolean isDisplayTraced() {
107 public static boolean isSortingTraced() {
112 public static void trace(String msg
) {
113 long currentTime
= System
.currentTimeMillis();
114 StringBuilder message
= new StringBuilder("[");
115 message
.append(currentTime
/ 1000);
117 message
.append(String
.format("%1$03d", currentTime
% 1000));
118 message
.append("] ");
121 if (fTraceLog
!= null) {
123 fTraceLog
.write(message
.toString());
126 } catch (IOException e
) {
132 public static void traceIndex(String msg
) {
133 String message
= ("[INDEX] " + msg
);
137 public static void traceDisplay(String msg
) {
138 String message
= ("[DISPLAY]" + msg
);
142 public static void traceSorting(String msg
) {
143 String message
= ("[SORT] " + msg
);
147 public static void traceError(String msg
) {
148 String message
= ("[ERR] Thread=" + Thread
.currentThread().getId() + " " + msg
);
152 public static void traceWarning(String msg
) {
153 String message
= ("[WARN] Thread=" + Thread
.currentThread().getId() + " " + msg
);
157 public static void traceInfo(String msg
) {
158 String message
= ("[INF] Thread=" + Thread
.currentThread().getId() + " " + msg
);
This page took 0.034531 seconds and 5 git commands to generate.