mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Method to allow customizing the line length in trace printouts
Change-Id: If89987dc3cbfce1d2a329968346b6a3908fa5196
This commit is contained in:
parent
74aa6f4e71
commit
74d67c7b38
1 changed files with 34 additions and 6 deletions
|
@ -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);
|
||||
|
@ -83,6 +100,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)
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue