22 package com.realtime.crossfire.jxclient.util;
24 import java.io.IOException;
25 import java.io.Writer;
26 import java.text.DateFormat;
27 import java.text.SimpleDateFormat;
28 import java.util.Date;
29 import org.jetbrains.annotations.NotNull;
47 private final DateFormat
simpleDateFormat =
new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss,SSS ");
53 private final Object
sync =
new Object();
70 writer.append(simpleDateFormat.format(
new Date()));
74 }
catch (
final IOException ex) {
75 System.err.println(
"Cannot write debug protocol: "+ex.getMessage());
77 throw new AssertionError(ex);
87 public void debugProtocolWrite(@NotNull
final CharSequence str, @NotNull
final Throwable throwable) {
90 writer.append(simpleDateFormat.format(
new Date()));
93 for (Throwable t = throwable; t != null; t = t.getCause()) {
94 writer.append(t.getClass().getName());
96 for (
final Object stack : t.getStackTrace()) {
97 writer.append(stack.toString());
102 }
catch (
final IOException ex) {
103 System.err.println(
"Cannot write debug protocol: "+ex.getMessage());
105 throw new AssertionError(ex);
void debugProtocolWrite(@NotNull final CharSequence str)
Writes a message to the debug protocol.
Writer debug information to a log file.
final DateFormat simpleDateFormat
A formatter for timestamps.
final Object sync
The object for synchronizing messages.
DebugWriter(@NotNull final Writer writer)
Creates a new instance.
final Writer writer
The Writer to write to.
void debugProtocolWrite(@NotNull final CharSequence str, @NotNull final Throwable throwable)
Writes a message to the debug protocol including a throwable.