package com.salvis.emptracker;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

import twitter4j.Status;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.conf.ConfigurationBuilder;

public class TwitterEmpTracker {
	static final String PROPERTY_FILE = System.getProperty("user.home") + File.separator + "emptracker.properties";

	private Twitter twitter;

	public TwitterEmpTracker() {
		Properties p = new Properties();
		try {
			FileInputStream fis = new FileInputStream(PROPERTY_FILE);
			p.load(fis);
			fis.close();
			ConfigurationBuilder cb = new ConfigurationBuilder();
			cb.setDebugEnabled(p.getProperty("debug", "false").equals("true"))
				.setOAuthConsumerKey(p.getProperty("oauth.consumerKey"))
				.setOAuthConsumerSecret(p.getProperty("oauth.consumerSecret"))
				.setOAuthAccessToken(p.getProperty("oauth.accessToken"))
				.setOAuthAccessTokenSecret(p.getProperty("oauth.accessTokenSecret"));
			TwitterFactory tf = new TwitterFactory(cb.build());
			twitter = tf.getInstance();
		} catch (FileNotFoundException e) {
			throw new RuntimeException("Property file " + PROPERTY_FILE + " is missing.");
		} catch (IOException e) {
			throw new RuntimeException("Error reading " + PROPERTY_FILE + ".");
		}
	}

	public Status updateStatus(String text) {
		try {
			return twitter.updateStatus(text);
		} catch (TwitterException e) {
			throw new RuntimeException(e.getMessage());
		}
	}
}

@@ -174,16 +174,49 @@
 rties;%0A%0A
+import org.apache.log4j.Logger;%0A%0A
 import t
@@ -517,16 +517,101 @@
 rties%22;%0A
+%09private final Logger logger = Logger.getLogger(TextMessageListener.class.getName());
 %0A%09privat
@@ -1495,16 +1495,65 @@
 %22);%0A%09%09%7D%0A
+%09%09logger.info(%22TwitterEmpTracker initialized.%22);%0A
 %09%7D%0A%0A%09pub
@@ -1606,14 +1606,23 @@
 %0A%09%09%09
-return
+Status status =
  twi
@@ -1646,16 +1646,105 @@
 (text);%0A
+%09%09%09logger.info(status.getUser().getScreenName() + %22 status updated.%22);%0A%09%09%09return status;%0A
 %09%09%7D catc

add logging messages