Skip to content

Commit 8313c8e

Browse files
authored
use JDK logging utils in debug.plugin package (microsoft#15)
1 parent 49cc96a commit 8313c8e

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JavaDebugServer.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818
import java.util.concurrent.SynchronousQueue;
1919
import java.util.concurrent.ThreadPoolExecutor;
2020
import java.util.concurrent.TimeUnit;
21+
import java.util.logging.Logger;
2122

22-
import com.microsoft.java.debug.core.Logger;
23+
import com.microsoft.java.debug.core.Configuration;
2324
import com.microsoft.java.debug.core.adapter.ProtocolServer;
2425

2526
public class JavaDebugServer implements IDebugServer {
27+
private static final Logger logger = Logger.getLogger(Configuration.LOGGER_NAME);
2628
private static JavaDebugServer singletonInstance;
2729

2830
private ServerSocket serverSocket = null;
@@ -33,7 +35,7 @@ private JavaDebugServer() {
3335
try {
3436
this.serverSocket = new ServerSocket(0, 1);
3537
} catch (IOException e) {
36-
Logger.logException("Failed to create Java Debug Server", e);
38+
logger.severe(String.format("Failed to create Java Debug Server: %s", e));
3739
}
3840
}
3941

@@ -78,7 +80,7 @@ public void run() {
7880
Socket connection = serverSocket.accept();
7981
executor.submit(createConnectionTask(connection));
8082
} catch (IOException e1) {
81-
Logger.logException("Setup socket connection exception", e1);
83+
logger.severe(String.format("Setup socket connection exception: %s", e1));
8284
closeServerSocket();
8385
// If exception occurs when waiting for new client connection, shut down the connection pool
8486
// to make sure no new tasks are accepted. But the previously submitted tasks will continue to run.
@@ -100,10 +102,10 @@ public synchronized void stop() {
100102
private synchronized void closeServerSocket() {
101103
if (serverSocket != null) {
102104
try {
103-
Logger.logInfo("Close debugserver socket port " + serverSocket.getLocalPort());
105+
logger.info("Close debugserver socket port " + serverSocket.getLocalPort());
104106
serverSocket.close();
105107
} catch (IOException e) {
106-
Logger.logException("Close ServerSocket exception", e);
108+
logger.severe(String.format("Close ServerSocket exception: %s", e));
107109
}
108110
}
109111
serverSocket = null;
@@ -128,9 +130,9 @@ public void run() {
128130
// protocol server will dispatch request and send response in a while-loop.
129131
protocolServer.start();
130132
} catch (IOException e) {
131-
Logger.logException("Socket connection exception", e);
133+
logger.severe(String.format("Socket connection exception: %s", e));
132134
} finally {
133-
Logger.logInfo("Debug connection closed");
135+
logger.info("Debug connection closed");
134136
}
135137
}
136138
};

com.microsoft.java.debug.plugin/src/main/java/com/microsoft/java/debug/plugin/internal/JdtSourceLookUpProvider.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.ArrayList;
66
import java.util.HashMap;
77
import java.util.Map;
8+
import java.util.logging.Logger;
89

910
import org.eclipse.core.resources.IProject;
1011
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -32,13 +33,14 @@
3233
import org.eclipse.jdt.internal.debug.core.breakpoints.ValidBreakpointLocationLocator;
3334
import org.eclipse.jdt.ls.core.internal.JDTUtils;
3435

36+
import com.microsoft.java.debug.core.Configuration;
3537
import com.microsoft.java.debug.core.DebugException;
36-
import com.microsoft.java.debug.core.Logger;
3738
import com.microsoft.java.debug.core.adapter.AdapterUtils;
3839
import com.microsoft.java.debug.core.adapter.Constants;
3940
import com.microsoft.java.debug.core.adapter.ISourceLookUpProvider;
4041

4142
public class JdtSourceLookUpProvider implements ISourceLookUpProvider {
43+
private static final Logger logger = Logger.getLogger(Configuration.LOGGER_NAME);
4244
private HashMap<String, Object> context = new HashMap<String, Object>();
4345
private static final String JDT_SCHEME = "jdt";
4446
private static final String PATH_SEPARATOR = "/";
@@ -143,7 +145,7 @@ private String getContents(IClassFile cf) {
143145
source = JDTUtils.disassemble(cf);
144146
}
145147
} catch (JavaModelException e) {
146-
Logger.logException("Failed to parse the source contents of the class file", e);
148+
logger.severe(String.format("Failed to parse the source contents of the class file: %s", e));
147149
}
148150
if (source == null) {
149151
source = "";
@@ -198,7 +200,7 @@ public void acceptSearchMatch(SearchMatch match) {
198200
null /* progress monitor */);
199201
return uris.size() == 0 ? null : uris.get(0);
200202
} catch (CoreException e) {
201-
Logger.logException("Failed to parse java project", e);
203+
logger.severe(String.format("Failed to parse java project: %s", e));
202204
}
203205
return null;
204206
}

0 commit comments

Comments
 (0)