+ /**
+ * 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;
+ }
+