Author: alexlehm
Date: 2007-11-22 22:09:36 +0000 (Thu, 22 Nov 2007)
New Revision: 15931
Modified:
trunk/apps/Freemail/src/freemail/AccountManager.java
trunk/apps/Freemail/src/freemail/AckProcrastinator.java
trunk/apps/Freemail/src/freemail/FreemailPlugin.java
trunk/apps/Freemail/src/freemail/InboundContact.java
trunk/apps/Freemail/src/freemail/MailHeaderFilter.java
trunk/apps/Freemail/src/freemail/MailSite.java
trunk/apps/Freemail/src/freemail/MessageSender.java
trunk/apps/Freemail/src/freemail/NIMFetcher.java
trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java
trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java
trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java
trunk/apps/Freemail/src/freemail/fcp/HighLevelFCPClient.java
trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java
trunk/apps/Freemail/src/freemail/imap/IMAPListener.java
trunk/apps/Freemail/src/freemail/smtp/SMTPHandler.java
trunk/apps/Freemail/src/freemail/smtp/SMTPListener.java
trunk/apps/Freemail/src/freemail/utils/Logger.java
Log:
added Logger calls to almost any output except FreemailCli
added support for static methods, changed a few calls to error
Modified: trunk/apps/Freemail/src/freemail/AccountManager.java
===================================================================
--- trunk/apps/Freemail/src/freemail/AccountManager.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/AccountManager.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -48,6 +48,7 @@
import freemail.fcp.SSKKeyPair;
import freemail.utils.PropsFile;
import freemail.utils.EmailAddress;
+import freemail.utils.Logger;
public class AccountManager {
public static final String DATADIR = "data";
@@ -137,7 +138,7 @@
try {
mailsite = new
FreenetURI(accfile.get("mailsite.pubkey"));
} catch (MalformedURLException mfue) {
- System.out.println("Warning: Couldn't fetch mailsite
public key from account file! Your account file is probably corrupt.");
+ Logger.error(AccountManager.class,"Warning: Couldn't
fetch mailsite public key from account file! Your account file is probably
corrupt.");
return null;
}
@@ -161,7 +162,7 @@
String privexp_str = props.get("asymkey.privexponent");
if (mod_str == null || privexp_str == null) {
- System.out.println("Couldn't get private key - account
file corrupt?");
+ Logger.error(AccountManager.class,"Couldn't get private
key - account file corrupt?");
return null;
}
@@ -170,7 +171,7 @@
private static void initAccFile(PropsFile accfile) {
try {
- System.out.println("Generating mailsite keys...");
+ Logger.normal(AccountManager.class,"Generating mailsite
keys...");
HighLevelFCPClient fcpcli = new HighLevelFCPClient();
SSKKeyPair keypair = null;
@@ -181,7 +182,7 @@
}
if (keypair == null) {
- System.out.println("Unable to connect to the
Freenet node");
+ Logger.normal(AccountManager.class,"Unable to
connect to the Freenet node");
return;
}
@@ -208,14 +209,14 @@
throw new IOException("Unable to write account
file");
}
- System.out.println("Mailsite keys generated.");
- System.out.println("Your Freemail address is any
username followed by '@"+getFreemailDomain(accfile)+"'");
+ Logger.normal(AccountManager.class,"Mailsite keys
generated.");
+ Logger.normal(AccountManager.class,"Your Freemail
address is any username followed by '@"+getFreemailDomain(accfile)+"'");
} catch (IOException ioe) {
- System.out.println("Couldn't create mailsite key file!
"+ioe.getMessage());
+ Logger.error(AccountManager.class,"Couldn't create
mailsite key file! "+ioe.getMessage());
}
// generate an RSA keypair
- System.out.println("Generating cryptographic keypair (this
could take a few minutes)...");
+ Logger.normal(AccountManager.class,"Generating cryptographic
keypair (this could take a few minutes)...");
SecureRandom rand = new SecureRandom();
@@ -232,7 +233,7 @@
accfile.put("asymkey.pubexponent",
pub.getExponent().toString(32));
accfile.put("asymkey.privexponent",
priv.getExponent().toString(32));
- System.out.println("Account creation completed.");
+ Logger.normal(AccountManager.class,"Account creation
completed.");
}
public static void addShortAddress(String username, String alias)
throws Exception {
Modified: trunk/apps/Freemail/src/freemail/AckProcrastinator.java
===================================================================
--- trunk/apps/Freemail/src/freemail/AckProcrastinator.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/AckProcrastinator.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -33,6 +33,7 @@
import freemail.fcp.FCPBadFileException;
import freemail.fcp.FCPInsertErrorMessage;
import freemail.fcp.ConnectionTerminatedException;
+import freemail.utils.Logger;
/** Takes simple pieces of data to insert to keys and inserts them at some
point
* randomly within a given time frame in order to disguise the time at which
messages
@@ -104,15 +105,15 @@
ByteArrayInputStream bis = new
ByteArrayInputStream(data);
- System.out.println("Inserting ack to
"+key);
+ Logger.normal(this,"Inserting ack to
"+key);
try {
FCPInsertErrorMessage err =
fcpcli.put(bis, key);
if (err == null) {
acks[i].delete();
- System.out.println("ACK
insertion to "+key+" sucessful");
+ Logger.normal(this,"ACK
insertion to "+key+" sucessful");
} else if (err.errorcode ==
FCPInsertErrorMessage.COLLISION) {
acks[i].delete();
- System.out.println("ACK
insertion to "+key+" sucessful");
+ Logger.normal(this,"ACK
insertion to "+key+" sucessful");
}
} catch (FCPBadFileException bfe) {
// won't occur
@@ -168,7 +169,7 @@
ackfile.put("nominalInsertTime",
Long.toString(insertTime));
} catch (IOException ioe) {
- System.out.println("IO Error whilst trying to schedule
ACK for insertion! ACK will not be inserted!");
+ Logger.error(AccountManager.class,"IO Error whilst
trying to schedule ACK for insertion! ACK will not be inserted!");
ioe.printStackTrace();
}
Modified: trunk/apps/Freemail/src/freemail/FreemailPlugin.java
===================================================================
--- trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/FreemailPlugin.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -34,6 +34,7 @@
import freemail.imap.IMAPListener;
import freemail.smtp.SMTPListener;
import freemail.config.Configurator;
+import freemail.utils.Logger;
import freenet.pluginmanager.FredPlugin;
import freenet.pluginmanager.FredPluginHTTP;
@@ -77,21 +78,21 @@
cfg.register("globaldatadir", new Freemail(), GLOBALDATADIR);
if (!getGlobalDataDir().exists()) {
if(!getGlobalDataDir().mkdir()) {
- System.out.println("Freemail plugin: Couldn't
create global data directory. Please ensure that the user you are running
Freemail as has write access to its working directory");
+ Logger.error(this,"Freemail plugin: Couldn't
create global data directory. Please ensure that the user you are running
Freemail as has write access to its working directory");
return;
}
}
cfg.register("datadir", new Freemail(), Freemail.DATADIR);
if (!getDataDir().exists()) {
if (!getDataDir().mkdir()) {
- System.out.println("Freemail plugin: Couldn't
create data directory. Please ensure that the user you are running Freemail as
has write access to its working directory");
+ Logger.error(this,"Freemail plugin: Couldn't
create data directory. Please ensure that the user you are running Freemail as
has write access to its working directory");
return;
}
}
cfg.register("tempdir", new Freemail(), Freemail.TEMPDIRNAME);
if (!getTempDir().exists()) {
if (!Freemail.getTempDir().mkdir()) {
- System.out.println("Freemail plugin: Couldn't
create temporary directory. Please ensure that the user you are running
Freemail as has write access to its working directory");
+ Logger.error(this,"Freemail plugin: Couldn't
create temporary directory. Please ensure that the user you are running
Freemail as has write access to its working directory");
return;
}
}
Modified: trunk/apps/Freemail/src/freemail/InboundContact.java
===================================================================
--- trunk/apps/Freemail/src/freemail/InboundContact.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/InboundContact.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -73,7 +73,7 @@
String slots = this.ibct_props.get("slots");
if (slots == null) {
- Logger.normal(this,"Contact "+this.ibct_dir.getName()+"
is corrupt - account file has no 'slots' entry!");
+ Logger.error(this,"Contact "+this.ibct_dir.getName()+"
is corrupt - account file has no 'slots' entry!");
// TODO: probably delete the contact. it's useless now.
return;
}
@@ -83,7 +83,7 @@
String basekey = this.ibct_props.get("commssk");
if (basekey == null) {
- Logger.normal(this,"Contact "+this.ibct_dir.getName()+"
is corrupt - account file has no 'commssk' entry!");
+ Logger.error(this,"Contact "+this.ibct_dir.getName()+"
is corrupt - account file has no 'commssk' entry!");
// TODO: probably delete the contact. it's useless now.
return;
}
@@ -118,7 +118,7 @@
PropsFile msgprops = new PropsFile(msg, true);
String s_id = msgprops.get("id");
if (s_id == null) {
- Logger.normal(this,"Got a message with an
invalid header. Discarding.");
+ Logger.error(this,"Got a message with an
invalid header. Discarding.");
sm.slotUsed();
msgprops.closeReader();
msg.delete();
@@ -129,7 +129,7 @@
try {
id = Integer.parseInt(s_id);
} catch (NumberFormatException nfe) {
- Logger.normal(this,"Got a message with an
invalid (non-integer) id. Discarding.");
+ Logger.error(this,"Got a message with an
invalid (non-integer) id. Discarding.");
sm.slotUsed();
msgprops.closeReader();
msg.delete();
@@ -141,7 +141,7 @@
try {
isDupe = msglog.isPresent(id);
} catch (IOException ioe) {
- Logger.normal(this,"Couldn't read logfile, so
don't know whether received message is a duplicate or not. Leaving in the queue
to try later.");
+ Logger.error(this,"Couldn't read logfile, so
don't know whether received message is a duplicate or not. Leaving in the queue
to try later.");
msgprops.closeReader();
msg.delete();
continue;
@@ -156,7 +156,7 @@
BufferedReader br = msgprops.getReader();
if (br == null) {
- Logger.normal(this,"Got an invalid message.
Discarding.");
+ Logger.error(this,"Got an invalid message.
Discarding.");
sm.slotUsed();
msgprops.closeReader();
msg.delete();
@@ -180,11 +180,11 @@
msglog.add(id);
} catch (IOException ioe) {
// how should we handle this? Remove the message
from the inbox again?
- Logger.normal(this,"warning: failed to write log
file!");
+ Logger.error(this,"warning: failed to write log
file!");
}
String ack_key = this.ibct_props.get("ackssk");
if (ack_key == null) {
- Logger.normal(this,"Warning! Can't send message
acknowledgement - don't have an 'ackssk' entry! This message will eventually
bounce, even though you've received it.");
+ Logger.error(this,"Warning! Can't send message
acknowledgement - don't have an 'ackssk' entry! This message will eventually
bounce, even though you've received it.");
continue;
}
ack_key += "ack-"+id;
@@ -216,11 +216,12 @@
// network connection is healthy, and the
mailsite
// ought to be easily retrievable, so fail.
// If this proves to be an issue, change it.
- Logger.normal(this,"Failed to fetch sender's
mailsite. Sender's From address therefore not valid.");
+ Logger.error(this,"Failed to fetch sender's
mailsite. Sender's From address therefore not valid.");
return false;
}
Logger.normal(this,"Fetched sender's mailsite");
if (result.length() > 512) {
+ Logger.error(this,"Sender's mailsite is too
long. Consider this an error.");
result.delete();
return false;
}
Modified: trunk/apps/Freemail/src/freemail/MailHeaderFilter.java
===================================================================
--- trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/MailHeaderFilter.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -35,6 +35,8 @@
import java.text.ParseException;
import java.util.Locale;
+import freemail.utils.Logger;
+
class MailHeaderFilter {
private final BufferedReader reader;
private final StringBuffer buffer;
@@ -67,7 +69,7 @@
String line = this.reader.readLine();
if (line == null) {
- System.out.println("Warning - reached end of
message file before reaching end of headers! This shouldn't happen!");
+ Logger.error(this,"Warning - reached end of
message file before reaching end of headers! This shouldn't happen!");
throw new IOException("Header filter reached
end of message file before reaching end of headers");
}
@@ -117,14 +119,14 @@
d = sdf.parse(val);
} catch (ParseException pe) {
// ...the compiler whinges unless we catch this
exception...
- System.out.println("Warning: couldn't parse
date: "+val+" (caught exception)");
+ Logger.normal(this,"Warning: couldn't parse
date: "+val+" (caught exception)");
return null;
}
// but the docs don't say that it throws it, but says
that it return null
//
http://java.sun.com/j2se/1.5.0/docs/api/java/text/SimpleDateFormat.html#parse(java.lang.String,
java.text.ParsePosition)
if (d == null) {
// invalid date - ditch the header
- System.out.println("Warning: couldn't parse
date: "+val+" (got null)");
+ Logger.normal(this,"Warning: couldn't parse
date: "+val+" (got null)");
return null;
}
return sdf.format(d);
Modified: trunk/apps/Freemail/src/freemail/MailSite.java
===================================================================
--- trunk/apps/Freemail/src/freemail/MailSite.java 2007-11-22 20:31:42 UTC
(rev 15930)
+++ trunk/apps/Freemail/src/freemail/MailSite.java 2007-11-22 22:09:36 UTC
(rev 15931)
@@ -30,6 +30,7 @@
import freemail.fcp.FCPInsertErrorMessage;
import freemail.fcp.FCPBadFileException;
import freemail.fcp.ConnectionTerminatedException;
+import freemail.utils.Logger;
public class MailSite {
private final PropsFile accprops;
@@ -45,21 +46,21 @@
String rtsksk = this.accprops.get("rtskey");
if (rtsksk == null) {
- System.out.println("Can't insert mailsite - missing RTS
KSK");
+ Logger.error(this,"Can't insert mailsite - missing RTS
KSK");
return null;
}
buf.append("rtsksk=").append(rtsksk).append("\r\n");
String keymodulus = this.accprops.get("asymkey.modulus");
if (keymodulus == null) {
- System.out.println("Can't insert mailsite - missing
asymmetic crypto key modulus");
+ Logger.error(this,"Can't insert mailsite - missing
asymmetic crypto key modulus");
return null;
}
buf.append("asymkey.modulus=").append(keymodulus).append("\r\n");
String key_pubexponent =
this.accprops.get("asymkey.pubexponent");
if (key_pubexponent == null) {
- System.out.println("Can't insert mailsite - missing
asymmetic crypto key public exponent");
+ Logger.error(this,"Can't insert mailsite - missing
asymmetic crypto key public exponent");
return null;
}
buf.append("asymkey.pubexponent=").append(key_pubexponent).append("\r\n");
@@ -127,7 +128,7 @@
ByteArrayInputStream bis = new
ByteArrayInputStream(targetKey.getBytes());
- System.out.println("Inserting mailsite redirect from
"+"KSK@"+alias+ALIAS_SUFFIX+" to "+targetKey);
+ Logger.normal(this,"Inserting mailsite redirect from
"+"KSK@"+alias+ALIAS_SUFFIX+" to "+targetKey);
HighLevelFCPClient cli = new HighLevelFCPClient();
@@ -141,13 +142,13 @@
}
if (err == null) {
- System.out.println("Mailsite redirect inserted
successfully");
+ Logger.normal(this,"Mailsite redirect inserted
successfully");
return true;
} else if (err.errorcode == FCPInsertErrorMessage.COLLISION) {
- System.out.println("Mailsite alias collided - somebody
is already using that alias! Choose another one!");
+ Logger.error(this,"Mailsite alias collided - somebody
is already using that alias! Choose another one!");
return false;
} else {
- System.out.println("Mailsite redirect insert failed,
but did not collide.");
+ Logger.error(this,"Mailsite redirect insert failed, but
did not collide.");
return false;
}
}
Modified: trunk/apps/Freemail/src/freemail/MessageSender.java
===================================================================
--- trunk/apps/Freemail/src/freemail/MessageSender.java 2007-11-22 20:31:42 UTC
(rev 15930)
+++ trunk/apps/Freemail/src/freemail/MessageSender.java 2007-11-22 22:09:36 UTC
(rev 15931)
@@ -32,6 +32,7 @@
import freemail.utils.EmailAddress;
import freemail.utils.DateStringFactory;
import freemail.fcp.ConnectionTerminatedException;
+import freemail.utils.Logger;
public class MessageSender implements Runnable {
/**
@@ -160,7 +161,7 @@
EmailAddress addr;
int tries;
if (parts.length < 3) {
- System.out.println("Warning invalid file in outbox -
deleting.");
+ Logger.error(this,"Warning invalid file in outbox -
deleting.");
msg.delete();
return;
} else {
@@ -200,7 +201,7 @@
}
private boolean sendSecure(File accdir, EmailAddress addr, File msg)
throws ConnectionTerminatedException {
- System.out.println("sending secure");
+ Logger.normal(this,"sending secure");
OutboundContact ct;
try {
ct = new OutboundContact(accdir, addr);
Modified: trunk/apps/Freemail/src/freemail/NIMFetcher.java
===================================================================
--- trunk/apps/Freemail/src/freemail/NIMFetcher.java 2007-11-22 20:31:42 UTC
(rev 15930)
+++ trunk/apps/Freemail/src/freemail/NIMFetcher.java 2007-11-22 22:09:36 UTC
(rev 15931)
@@ -24,6 +24,7 @@
import freemail.fcp.HighLevelFCPClient;
import freemail.fcp.ConnectionTerminatedException;
import freemail.utils.DateStringFactory;
+import freemail.utils.Logger;
import java.io.File;
import java.io.FileReader;
@@ -84,12 +85,12 @@
int startnum = log.getNextMessageId();
for (int i = startnum; i < startnum + POLL_AHEAD; i++) {
- System.out.println("trying to fetch "+keybase+i);
+ Logger.normal(this,"trying to fetch "+keybase+i);
File result = fcpcli.fetch(keybase+i);
if (result != null) {
- System.out.println(keybase+i+": got message!");
+ Logger.normal(this,keybase+i+": got message!");
try {
this.storeMessage(new
BufferedReader(new FileReader(result)), this.mb);
result.delete();
@@ -98,7 +99,7 @@
continue;
}
} else {
- System.out.println(keybase+i+": no message.");
+ Logger.normal(this,keybase+i+": no message.");
}
}
}
Modified: trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java
===================================================================
--- trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/SingleAccountWatcher.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -26,6 +26,7 @@
import freemail.utils.PropsFile;
import freemail.fcp.ConnectionTerminatedException;
+import freemail.utils.Logger;
public class SingleAccountWatcher implements Runnable {
/**
@@ -79,13 +80,13 @@
//this.mf = new MailFetcher(this.mb, inbound_dir,
Freemail.getFCPConnection());
// temporary info message until there's a nicer UI :)
- System.out.println("Secure Freemail address:
<anything>@"+AccountManager.getFreemailDomain(accdir));
+ Logger.normal(this,"Secure Freemail address:
<anything>@"+AccountManager.getFreemailDomain(accdir));
String shortdomain =
AccountManager.getKSKFreemailDomain(accdir);
if (shortdomain != null) {
- System.out.println("Short Freemail address (*probably*
secure): <anything>@"+shortdomain);
+ Logger.normal(this,"Short Freemail address (*probably*
secure): <anything>@"+shortdomain);
} else {
- System.out.println("You don't have a short Freemail
address. You could get one by running Freemail with the --shortaddress option,
followed by your account name and the name you'd like. For example, 'java -jar
freemail.jar --shortaddress bob bob' will give you all addresses ending
'@bob.freemail'. Try to pick something unique!");
+ Logger.normal(this,"You don't have a short Freemail
address. You could get one by running Freemail with the --shortaddress option,
followed by your account name and the name you'd like. For example, 'java -jar
freemail.jar --shortaddress bob bob' will give you all addresses ending
'@bob.freemail'. Try to pick something unique!");
}
}
Modified: trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java
===================================================================
--- trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/fcp/FCPConnection.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -28,6 +28,8 @@
import java.util.HashMap;
import java.util.Iterator;
+import freemail.utils.Logger;
+
public class FCPConnection implements Runnable {
/**
* Whether the thread this service runs in should stop.
@@ -62,12 +64,12 @@
hello.writeto(this.os);
FCPMessage reply = this.getMessage();
if (reply.getType() == null) {
- System.out.println("Connection closed");
+ Logger.error(this,"Connection closed");
this.conn = null;
return;
}
if (!reply.getType().equals("NodeHello")) {
- System.out.println("Warning - got
'"+reply.getType()+"' from node, expecting 'NodeHello'");
+ Logger.error(this,"Warning - got
'"+reply.getType()+"' from node, expecting 'NodeHello'");
}
} catch (IOException ioe) {
this.conn = null;
Modified: trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java
===================================================================
--- trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/fcp/FCPMessage.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -61,7 +61,7 @@
String line;
while ( (line = r.readLine(200, 200, false)) != null) {
/***************************************/
- //System.out.println(line);
+ //Logger.normal(this,line);
if (this.messagetype == null) {
this.messagetype = line;
} else if (line.startsWith("End")) {
@@ -187,7 +187,7 @@
buf.append("EndMessage\r\n");
}
if (buf.length() > 0) {
- //System.out.println(buf.toString());
+ //Logger.normal(this,buf.toString());
os.write(buf.toString().getBytes());
}
if (this.outData != null) {
Modified: trunk/apps/Freemail/src/freemail/fcp/HighLevelFCPClient.java
===================================================================
--- trunk/apps/Freemail/src/freemail/fcp/HighLevelFCPClient.java
2007-11-22 20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/fcp/HighLevelFCPClient.java
2007-11-22 22:09:36 UTC (rev 15931)
@@ -28,6 +28,7 @@
import java.io.FileNotFoundException;
import freemail.Freemail;
+import freemail.utils.Logger;
public class HighLevelFCPClient implements FCPClient {
private static final int FCP_TOO_MANY_PATH_COMPONENTS = 11;
@@ -54,7 +55,7 @@
break;
} catch (NoNodeConnectionException nnce) {
try {
- System.out.println("got no conn
exception: "+nnce.getMessage());
+ Logger.error(this,"got no conn
exception: "+nnce.getMessage());
Thread.sleep(5000);
} catch (InterruptedException ie) {
}
@@ -98,7 +99,7 @@
break;
} catch (NoNodeConnectionException nnce) {
try {
- System.out.println("Warning - no
connection to node. Waiting...");
+ Logger.error(this,"Warning - no
connection to node. Waiting...");
Thread.sleep(5000);
} catch (InterruptedException ie) {
}
@@ -165,7 +166,7 @@
boolean carryon = true;
FileInputStream fis;
while (carryon) {
- System.out.println("trying slotinsert to
"+basekey+"-"+slot+suffix);
+ Logger.normal(this,"trying slotinsert to
"+basekey+"-"+slot+suffix);
try {
fis = new FileInputStream(data);
@@ -180,13 +181,13 @@
return -1;
}
if (emsg == null) {
- System.out.println("insert of
"+basekey+"-"+slot+suffix+" successful");
+ Logger.normal(this,"insert of
"+basekey+"-"+slot+suffix+" successful");
return slot;
} else if (emsg.errorcode ==
FCPInsertErrorMessage.COLLISION) {
slot++;
- System.out.println("collision");
+ Logger.normal(this,"collision");
} else {
- System.out.println("nope - error code is
"+emsg.errorcode);
+ Logger.error(this,"nope - error code is
"+emsg.errorcode);
// try again later
return -1;
}
@@ -199,7 +200,7 @@
boolean carryon = true;
ByteArrayInputStream bis;
while (carryon) {
- System.out.println("trying slotinsert to
"+basekey+"-"+slot+suffix);
+ Logger.normal(this,"trying slotinsert to
"+basekey+"-"+slot+suffix);
bis = new ByteArrayInputStream(data);
@@ -210,13 +211,13 @@
return -1;
}
if (emsg == null) {
- System.out.println("insert of
"+basekey+"-"+slot+suffix+" successful");
+ Logger.normal(this,"insert of
"+basekey+"-"+slot+suffix+" successful");
return slot;
} else if (emsg.errorcode ==
FCPInsertErrorMessage.COLLISION) {
slot++;
- System.out.println("collision");
+ Logger.normal(this,"collision");
} else {
- System.out.println("nope - error code is
"+emsg.errorcode);
+ Logger.error(this,"nope - error code is
"+emsg.errorcode);
// try again later
return -1;
}
Modified: trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java
===================================================================
--- trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/imap/IMAPHandler.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -83,7 +83,7 @@
}
private void dispatch(IMAPMessage msg) {
- //System.out.println(msg.toString());
+ //Logger.normal(this,msg.toString());
if (msg.type.equals("login")) {
this.handle_login(msg);
} else if (msg.type.equals("logout")) {
Modified: trunk/apps/Freemail/src/freemail/imap/IMAPListener.java
===================================================================
--- trunk/apps/Freemail/src/freemail/imap/IMAPListener.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/imap/IMAPListener.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -29,6 +29,7 @@
import freemail.ServerListener;
import freemail.config.Configurator;
import freemail.config.ConfigClient;
+import freemail.utils.Logger;
public class IMAPListener extends ServerListener implements
Runnable,ConfigClient {
private static final int LISTENPORT = 3143;
@@ -52,7 +53,7 @@
try {
this.realrun();
} catch (IOException ioe) {
- System.out.println("Error in IMAP server -
"+ioe.getMessage());
+ Logger.error(this,"Error in IMAP server -
"+ioe.getMessage());
}
}
Modified: trunk/apps/Freemail/src/freemail/smtp/SMTPHandler.java
===================================================================
--- trunk/apps/Freemail/src/freemail/smtp/SMTPHandler.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/smtp/SMTPHandler.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -69,7 +69,7 @@
while ( !this.client.isClosed() && (line =
this.bufrdr.readLine()) != null) {
SMTPCommand msg = null;
try {
- //System.out.println(line);
+ //Logger.normal(this,line);
msg = new SMTPCommand(line);
} catch (SMTPBadCommandException bce) {
continue;
@@ -85,7 +85,7 @@
}
private void dispatch(SMTPCommand cmd) {
- //System.out.println(cmd.toString());
+ //Logger.normal(this,cmd.toString());
if (cmd.command.equals("helo")) {
this.handle_helo(cmd);
} else if (cmd.command.equals("ehlo")) {
Modified: trunk/apps/Freemail/src/freemail/smtp/SMTPListener.java
===================================================================
--- trunk/apps/Freemail/src/freemail/smtp/SMTPListener.java 2007-11-22
20:31:42 UTC (rev 15930)
+++ trunk/apps/Freemail/src/freemail/smtp/SMTPListener.java 2007-11-22
22:09:36 UTC (rev 15931)
@@ -29,6 +29,7 @@
import freemail.ServerListener;
import freemail.config.ConfigClient;
import freemail.config.Configurator;
+import freemail.utils.Logger;
public class SMTPListener extends ServerListener implements
Runnable,ConfigClient {
private static final int LISTENPORT = 3025;
@@ -46,7 +47,7 @@
try {
this.realrun();
} catch (IOException ioe) {
- System.out.println("Error in SMTP server -
"+ioe.getMessage());
+ Logger.error(this,"Error in SMTP server -
"+ioe.getMessage());
}
}
Modified: trunk/apps/Freemail/src/freemail/utils/Logger.java
===================================================================
--- trunk/apps/Freemail/src/freemail/utils/Logger.java 2007-11-22 20:31:42 UTC
(rev 15930)
+++ trunk/apps/Freemail/src/freemail/utils/Logger.java 2007-11-22 22:09:36 UTC
(rev 15931)
@@ -22,26 +22,48 @@
//static final private int loglevel=DEBUG|NORMAL|ERROR;
static final private int loglevel=NORMAL|ERROR; // should be ok for
normal users
- static private void log(int l, Object t, String s, String level) {
+ static private void log(int l, Object o, String s, String level) {
if((l&loglevel)!=0) {
-
System.out.println(level+"("+t.getClass().getSimpleName()+"): "+s);
+
System.out.println(level+"("+o.getClass().getSimpleName()+"): "+s);
}
}
- static public void minor(Object t, String s) {
- log(MINOR,t,s,"MINOR");
+ static private void log(int l, Class c, String s, String level) {
+ if((l&loglevel)!=0) {
+ System.out.println(level+"("+c.getSimpleName()+"): "+s);
+ }
}
- static public void normal(Object t, String s) {
- log(NORMAL,t,s,"NORMAL");
+ static public void minor(Object o, String s) {
+ log(MINOR,o,s,"MINOR");
}
- static public void error(Object t, String s) {
- log(ERROR,t,s,"ERROR");
+ static public void minor(Class c, String s) {
+ log(MINOR,c,s,"MINOR");
}
- static public void debug(Object t, String s) {
- log(DEBUG,t,s,"DEBUG");
+ static public void normal(Object o, String s) {
+ log(NORMAL,o,s,"NORMAL");
}
+ static public void normal(Class c, String s) {
+ log(NORMAL,c,s,"NORMAL");
+ }
+
+ static public void error(Object o, String s) {
+ log(ERROR,o,s,"ERROR");
+ }
+
+ static public void error(Class c, String s) {
+ log(ERROR,c,s,"ERROR");
+ }
+
+ static public void debug(Object o, String s) {
+ log(DEBUG,o,s,"DEBUG");
+ }
+
+ static public void debug(Class c, String s) {
+ log(DEBUG,c,s,"DEBUG");
+ }
+
}