+ public static PrintStream logstream = System.err;
+
+ public static void flush() { logstream.flush(); }
+ public static void email(String address) { throw new Error("FIXME not supported"); }
+ public static void file(String filename) throws IOException {
+ // FIXME security
+ logstream = new PrintStream(new FileOutputStream(filename));
+ }
+ public static void tcp(String host, int port) throws IOException {
+ // FIXME security
+ logstream = new PrintStream(new Socket(InetAddress.getByName(host), port).getOutputStream());
+ }
+
+ private static Hashtable threadAnnotations = new Hashtable();
+ public static void setThreadAnnotation(String s) { threadAnnotations.put(Thread.currentThread(), s); }
+
+ /**
+ * Notes can be used to attach log messages to the current thread
+ * if you're not sure you want them in the log just yet.
+ * Originally designed for retroactively logging socket-level
+ * conversations only if an error is encountered
+ */
+ public static void note(String s) {
+ if (!notes) return;
+ StringBuffer notebuf = notebuf();
+ notebuf.append(s);
+ if (notebuf.length() > maximumNoteLength) {
+ notebuf.reverse();
+ notebuf.setLength(maximumNoteLength * 3 / 4);
+ notebuf.reverse();
+ }
+ }
+ public static void clearnotes() { if (!notes) return; notebuf().setLength(0); }
+ private static Hashtable notebufs = new Hashtable();
+ private static StringBuffer notebuf() {
+ StringBuffer ret = (StringBuffer)notebufs.get(Thread.currentThread());
+ if (ret == null) {
+ ret = new StringBuffer(16 * 1024);
+ notebufs.put(Thread.currentThread(), ret);
+ }
+ return ret;
+ }
+