1 package org.ibex.mail.target;
2 import org.ibex.mail.*;
3 import org.ibex.util.*;
10 /** a fast-write, slow-read place to stash all messages we touch -- in case of a major f*ckup */
11 public class Transcript extends Target {
13 public static final Transcript transcript = new Transcript(Mailbox.STORAGE_ROOT + File.separatorChar + "transcript");
16 public Transcript(String path) { new File(this.path = path).mkdirs(); }
17 private static String lastTime = null;
18 private static int lastCounter = 0;
20 public synchronized void accept(Message message) {
22 File today = new File(path + File.separatorChar + (new SimpleDateFormat("yy-MMM-dd").format(new Date())));
25 String time = new SimpleDateFormat("HH:mm:ss").format(new Date());
26 synchronized (Transcript.class) {
27 if (lastTime != null && lastTime.equals(time)) {
28 time += "." + (++lastCounter);
35 File target = new File(today.getPath() + File.separatorChar + time + ".txt");
36 OutputStream os = new FileOutputStream(target);
37 message.dump(new Stream(os));
40 } catch (IOException e) { throw new MailException.IOException(e); }