Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2017-02-10 16:41:45 +0000
committerMarc Khouzam2017-02-13 16:49:13 +0000
commit74d67c7b38057006ce9bf7e539640da4c41a64d9 (patch)
tree9281a1a2c99d00774fe134580c9925e9733ca86f /dsf-gdb/org.eclipse.cdt.dsf.gdb/src
parent74aa6f4e71af08cc64151cbb1243ba3723dabeca (diff)
downloadorg.eclipse.cdt-74d67c7b38057006ce9bf7e539640da4c41a64d9.tar.gz
org.eclipse.cdt-74d67c7b38057006ce9bf7e539640da4c41a64d9.tar.xz
org.eclipse.cdt-74d67c7b38057006ce9bf7e539640da4c41a64d9.zip
Method to allow customizing the line length in trace printouts
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb/src')
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbDebugOptions.java40
1 files changed, 34 insertions, 6 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbDebugOptions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbDebugOptions.java
index fd4e3381c61..3db5fe29c40 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbDebugOptions.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/GdbDebugOptions.java
@@ -68,12 +68,29 @@ public class GdbDebugOptions implements DebugOptionsListener {
* @param throwable the {@link Throwable} or <code>null</code>
*/
public static void trace(String option, String message, Throwable throwable) {
- //divide the string into substrings of 100 chars or less for printing
- //to console
- String systemPrintableMessage = message;
- while (systemPrintableMessage.length() > 100) {
- String partial = systemPrintableMessage.substring(0, 100);
- systemPrintableMessage = systemPrintableMessage.substring(100);
+ trace(option, message, 100, throwable);
+ }
+
+ /**
+ * 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 lineMax the number of character at which point the line should be
+ * split. Minimum 100. Negative number to indicate no split.
+ * @param throwable the {@link Throwable} or <code>null</code>
+ */
+ public static void trace(String option, String message, int lineMax, Throwable throwable) {
+ if (lineMax < 0) {
+ lineMax = Integer.MAX_VALUE;
+ } else if (lineMax < 100) {
+ lineMax = 100;
+ }
+
+ //divide the string into substrings of 'lineMax' chars or less for printing to console
+ String systemPrintableMessage = message;
+ while (systemPrintableMessage.length() > lineMax) {
+ String partial = systemPrintableMessage.substring(0, lineMax);
+ systemPrintableMessage = systemPrintableMessage.substring(lineMax);
System.out.println(partial + "\\"); //$NON-NLS-1$
}
System.out.print(systemPrintableMessage);
@@ -87,6 +104,17 @@ public class GdbDebugOptions implements DebugOptionsListener {
* Prints the given message to System.out and to the OSGi tracing (if enabled)
*
* @param message the message or <code>null</code>
+ * @param lineMax the number of character at which point the line should be
+ * split. Minimum 100. Negative number to indicate no split.
+ */
+ public static void trace(String message, int lineMax) {
+ trace(null, message, lineMax, null);
+ }
+
+ /**
+ * Prints the given message to System.out and to the OSGi tracing (if enabled)
+ *
+ * @param message the message or <code>null</code>
*/
public static void trace(String message) {
trace(null, message, null);

Back to the top