Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Rennie2012-03-19 18:45:35 +0000
committerMike Rennie2012-03-19 18:45:35 +0000
commit90b44ce35ecdfbe54c20e2f2efb2a766a308e2a5 (patch)
tree7f59edfe86eb24b323199137dea522638dbd30a7 /org.eclipse.debug.core/core
parent9ab20e2ccd28123e2a275ddb8340a65f2e7ba6fd (diff)
downloadeclipse.platform.debug-90b44ce35ecdfbe54c20e2f2efb2a766a308e2a5.tar.gz
eclipse.platform.debug-90b44ce35ecdfbe54c20e2f2efb2a766a308e2a5.tar.xz
eclipse.platform.debug-90b44ce35ecdfbe54c20e2f2efb2a766a308e2a5.zip
Bug 374268 - Use the DebugTrace object to print to trace filesv20120319-1845
Diffstat (limited to 'org.eclipse.debug.core/core')
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java2
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java20
-rw-r--r--org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugOptions.java32
3 files changed, 43 insertions, 11 deletions
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
index 138e35d2b..50a9cea30 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/DebugPlugin.java
@@ -1138,7 +1138,7 @@ public class DebugPlugin extends Plugin {
Object[] listeners= getEventListeners();
if (DebugOptions.DEBUG_EVENTS) {
for (int i = 0; i < fEvents.length; i++) {
- System.out.println(fEvents[i]);
+ DebugOptions.trace(fEvents[i].toString());
}
}
for (int i= 0; i < listeners.length; i++) {
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java
index 82addc5ab..2d2128b7d 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/commands/AbstractDebugCommand.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * Copyright (c) 2006, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -68,11 +68,11 @@ public abstract class AbstractDebugCommand implements IDebugCommandHandler {
protected IStatus run(IProgressMonitor monitor) {
run = true;
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.print("can execute command: " + AbstractDebugCommand.this); //$NON-NLS-1$
+ DebugOptions.trace("can execute command: " + AbstractDebugCommand.this); //$NON-NLS-1$
}
if (monitor.isCanceled()) {
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> *CANCELED* <<"); //$NON-NLS-1$
+ DebugOptions.trace(" >> *CANCELED* <<"); //$NON-NLS-1$
}
request.cancel();
}
@@ -85,7 +85,7 @@ public abstract class AbstractDebugCommand implements IDebugCommandHandler {
request.setEnabled(false);
request.cancel();
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> false (no adapter)"); //$NON-NLS-1$
+ DebugOptions.trace(" >> false (no adapter)"); //$NON-NLS-1$
}
}
}
@@ -99,15 +99,15 @@ public abstract class AbstractDebugCommand implements IDebugCommandHandler {
try {
boolean executable = isExecutable(targets, monitor, request);
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> " + executable); //$NON-NLS-1$
+ DebugOptions.trace(" >> " + executable); //$NON-NLS-1$
}
request.setEnabled(executable);
} catch (CoreException e) {
request.setStatus(e.getStatus());
request.setEnabled(false);
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> ABORTED"); //$NON-NLS-1$
- System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
+ DebugOptions.trace(" >> ABORTED"); //$NON-NLS-1$
+ DebugOptions.trace("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
}
}
}
@@ -140,7 +140,7 @@ public abstract class AbstractDebugCommand implements IDebugCommandHandler {
request.cancel();
request.done();
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println(" >> *CANCELED* <<" + AbstractDebugCommand.this); //$NON-NLS-1$
+ DebugOptions.trace(" >> *CANCELED* <<" + AbstractDebugCommand.this); //$NON-NLS-1$
}
}
getJobManager().removeJobChangeListener(this);
@@ -200,7 +200,7 @@ public abstract class AbstractDebugCommand implements IDebugCommandHandler {
Job job = new Job(getExecuteTaskName()) {
protected IStatus run(IProgressMonitor monitor) {
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println("execute: " + AbstractDebugCommand.this); //$NON-NLS-1$
+ DebugOptions.trace("execute: " + AbstractDebugCommand.this); //$NON-NLS-1$
}
Object[] elements = request.getElements();
Object[] targets = new Object[elements.length];
@@ -214,7 +214,7 @@ public abstract class AbstractDebugCommand implements IDebugCommandHandler {
} catch (CoreException e) {
request.setStatus(e.getStatus());
if (DebugOptions.DEBUG_COMMANDS) {
- System.out.println("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
+ DebugOptions.trace("\t" + e.getStatus().getMessage()); //$NON-NLS-1$
}
}
request.done();
diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugOptions.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugOptions.java
index 3449f607a..f92e8b263 100644
--- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugOptions.java
+++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/DebugOptions.java
@@ -14,6 +14,7 @@ import java.util.Hashtable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.osgi.service.debug.DebugOptionsListener;
+import org.eclipse.osgi.service.debug.DebugTrace;
import org.osgi.framework.BundleContext;
/**
@@ -33,6 +34,12 @@ public class DebugOptions implements DebugOptionsListener {
static final String DEBUG_FLAG_EVENTS = "org.eclipse.debug.core/debug/events"; //$NON-NLS-1$
/**
+ * The {@link DebugTrace} object to print to OSGi tracing
+ * @since 3.8
+ */
+ private static DebugTrace fgDebugTrace;
+
+ /**
* Constructor
* @param context the bundle context
*/
@@ -46,8 +53,33 @@ public class DebugOptions implements DebugOptionsListener {
* @see org.eclipse.osgi.service.debug.DebugOptionsListener#optionsChanged(org.eclipse.osgi.service.debug.DebugOptions)
*/
public void optionsChanged(org.eclipse.osgi.service.debug.DebugOptions options) {
+ fgDebugTrace = options.newDebugTrace(DebugPlugin.getUniqueIdentifier());
DEBUG = options.getBooleanOption(DEBUG_FLAG, false);
DEBUG_COMMANDS = DEBUG & options.getBooleanOption(DEBUG_FLAG_COMMANDS, false);
DEBUG_EVENTS = DEBUG & options.getBooleanOption(DEBUG_FLAG_EVENTS, false);
}
+
+ /**
+ * Prints the given message to System.out and to the OSGi tracing (if started)
+ * @param option the option or <code>null</code>
+ * @param message the message to print or <code>null</code>
+ * @param throwable the {@link Throwable} or <code>null</code>
+ * @since 3.8
+ */
+ public static void trace(String option, String message, Throwable throwable) {
+ System.out.println(message);
+ if(fgDebugTrace != null) {
+ fgDebugTrace.trace(option, message, throwable);
+ }
+ }
+
+ /**
+ * Prints the given message to System.out and to the OSGi tracing (if enabled)
+ *
+ * @param message the message or <code>null</code>
+ * @since 3.8
+ */
+ public static void trace(String message) {
+ trace(null, message, null);
+ }
}

Back to the top