Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 286130
Collapse All | Expand All

(-)supplement/src/org/eclipse/osgi/framework/debug/EclipseDebugTrace.java (-4 / +36 lines)
Lines 40-46 Link Here
40
	/** The version attribute written to the header of the trace file */
40
	/** The version attribute written to the header of the trace file */
41
	private final static String TRACE_FILE_VERSION_COMMENT = "version: "; //$NON-NLS-1$
41
	private final static String TRACE_FILE_VERSION_COMMENT = "version: "; //$NON-NLS-1$
42
	/** The version value written to the header of the trace file */
42
	/** The version value written to the header of the trace file */
43
	private final static String TRACE_FILE_VERSION = "1.0"; //$NON-NLS-1$
43
	private final static String TRACE_FILE_VERSION = "1.1"; //$NON-NLS-1$
44
	/** The new session identifier to be written whenever a new session starts */
44
	/** The new session identifier to be written whenever a new session starts */
45
	private final static String TRACE_NEW_SESSION = "!SESSION "; //$NON-NLS-1$
45
	private final static String TRACE_NEW_SESSION = "!SESSION "; //$NON-NLS-1$
46
	/** The date attribute written to the header of the trace file to show when this file was created */
46
	/** The date attribute written to the header of the trace file to show when this file was created */
Lines 201-208 Link Here
201
					} else {
201
					} else {
202
						messageBuffer.append(EclipseDebugTrace.NULL_VALUE);
202
						messageBuffer.append(EclipseDebugTrace.NULL_VALUE);
203
					}
203
					}
204
					messageBuffer.append(" "); //$NON-NLS-1$
205
					i++;
204
					i++;
205
					if (i < methodArguments.length) {
206
						messageBuffer.append(" "); //$NON-NLS-1$
207
					}
206
				}
208
				}
207
				messageBuffer.append(")"); //$NON-NLS-1$
209
				messageBuffer.append(")"); //$NON-NLS-1$
208
			}
210
			}
Lines 459-464 Link Here
459
	}
461
	}
460
462
461
	/**
463
	/**
464
	 * Accessor to retrieve the text of a {@link Throwable} in a formatted manner so that it can be written to the
465
	 * trace file. 
466
	 * 
467
	 * @param error The {@lnk Throwable} to format
468
	 * @return The complete text of a {@link Throwable} as a {@link String} or null if the input error is null.
469
	 */
470
	private final String getFormattedThrowable(Throwable error) {
471
472
		String result = null;
473
		if (error != null) {
474
			PrintStream throwableStream = null;
475
			try {
476
				ByteArrayOutputStream throwableByteOutputStream = new ByteArrayOutputStream();
477
				throwableStream = new PrintStream(throwableByteOutputStream, false);
478
				error.printStackTrace(throwableStream);
479
				result = throwableByteOutputStream.toString();
480
			} finally {
481
				if (throwableStream != null) {
482
					throwableStream.close();
483
				}
484
			}
485
		}
486
		return result;
487
	}
488
489
	/**
462
	 * Writes header information to a new trace file
490
	 * Writes header information to a new trace file
463
	 * 
491
	 * 
464
	 * @param traceWriter the trace writer
492
	 * @param traceWriter the trace writer
Lines 487-493 Link Here
487
	private void writeMessage(final Writer traceWriter, final FrameworkDebugTraceEntry entry) throws IOException {
515
	private void writeMessage(final Writer traceWriter, final FrameworkDebugTraceEntry entry) throws IOException {
488
516
489
		// format the trace entry
517
		// format the trace entry
490
		StringBuffer message = new StringBuffer(entry.getThreadName());
518
		StringBuffer message = new StringBuffer(EclipseDebugTrace.TRACE_ELEMENT_DELIMITER);
519
		message.append(" "); //$NON-NLS-1$
520
		message.append(entry.getThreadName());
491
		message.append(" "); //$NON-NLS-1$
521
		message.append(" "); //$NON-NLS-1$
492
		message.append(EclipseDebugTrace.TRACE_ELEMENT_DELIMITER);
522
		message.append(EclipseDebugTrace.TRACE_ELEMENT_DELIMITER);
493
		message.append(" "); //$NON-NLS-1$
523
		message.append(" "); //$NON-NLS-1$
Lines 519-526 Link Here
519
		if (entry.getThrowable() != null) {
549
		if (entry.getThrowable() != null) {
520
			message.append(EclipseDebugTrace.TRACE_ELEMENT_DELIMITER);
550
			message.append(EclipseDebugTrace.TRACE_ELEMENT_DELIMITER);
521
			message.append(" "); //$NON-NLS-1$
551
			message.append(" "); //$NON-NLS-1$
522
			message.append(entry.getThrowable());
552
			message.append(this.getFormattedThrowable(entry.getThrowable()));
523
		}
553
		}
554
		message.append(" "); //$NON-NLS-1$
555
		message.append(EclipseDebugTrace.TRACE_ELEMENT_DELIMITER);
524
		message.append(EclipseDebugTrace.LINE_SEPARATOR);
556
		message.append(EclipseDebugTrace.LINE_SEPARATOR);
525
		// write the message
557
		// write the message
526
		if ((traceWriter != null) && (message != null)) {
558
		if ((traceWriter != null) && (message != null)) {

Return to bug 286130