Example usage for twitter4j Logger getLogger

List of usage examples for twitter4j Logger getLogger

Introduction

In this page you can find the example usage for twitter4j Logger getLogger.

Prototype

public static Logger getLogger(Class<?> clazz) 

Source Link

Document

Returns a Logger instance associated with the specified class.

Usage

From source file:com.TweetExtractor.java

/**
 * *//from   ww w.j av a 2 s  .c o m
 * Method to set up the API keys for the configuration builder
 */
private void buildConfiguration() throws IOException, SAXException, ParserConfigurationException {
    cb = new ConfigurationBuilder();
    Logger.getLogger(TweetExtractor.class).debug("Building Configuration");

    String consumerKey = "9Rk0BvBYIUZB4LiKZWmx00Dpl";
    String consumerSecret = "QmLCDeGkKgbpmxVQzFnAJoq2Wpgw3uj0AdE8VxvQRCymzSvCct";
    String accessToken = "1602877004-upomW5DK5e8BSUdhU7OW9mQzBBr05AqCbDxEzuQ";
    String accessTokenSecret = "aBaklu0v1iu4WidpqpulPjT6I8VqHOYHurTSgWK8aPcEi";
    maxTweets = 50;
    // userToSearch="dulsrazz";

    if (consumerKey == null || consumerSecret == null || accessToken == null || accessTokenSecret == null) {

        throw new NullPointerException("TWitter API Keys not set");
    }

    cb.setDebugEnabled(true).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret)
            .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret);
}

From source file:org.wso2.cep.uima.demo.StatusHandler.java

License:Open Source License

/***
 * Method to handle arrival of a status to the stream
 * @param status Recieved Tweet as a Status Object
 *//* www . j  ava 2s  .  c  o m*/
@Override
public void onStatus(Status status) {
    Logger.getLogger(StatusHandler.class).info("Tweet Recieved : " + status.getText());
    if (producer == null) {
        throw new NullPointerException("ActiveMQ producer not set for StatusHandler");
    }

    // send the tweet to the queue
    try {
        TextMessage tweetMessage = session.createTextMessage(status.getText());
        producer.send(tweetMessage);
    } catch (JMSException e) {
        e.printStackTrace();
    }

}

From source file:org.wso2.cep.uima.demo.StatusHandler.java

License:Open Source License

@Override
public void onException(Exception arg0) {
    Logger.getLogger(StatusHandler.class)
            .error("Exception occured while streaming for tweets : " + arg0.getMessage());
    arg0.printStackTrace();/*  w  w  w. j  av a 2  s  . c om*/
}

From source file:org.wso2.cep.uima.demo.StatusHandler.java

License:Open Source License

@Override
public void onTrackLimitationNotice(int arg0) {
    Logger.getLogger(StatusHandler.class).error("Track Limitations Exceeded");

}

From source file:org.wso2.cep.uima.demo.TweetExtractor.java

License:Open Source License

/***
 *  Method to set up the API keys for the configuration builder
 *///from   w w w . ja  v  a2 s. c o  m
private void buildConfiguration() throws IOException, SAXException, ParserConfigurationException {
    cb = new ConfigurationBuilder();
    Logger.getLogger(TweetExtractor.class).debug("Building Configuration");

    TwitterConfiguration config = TwitterConfigurationBuilder.getTwitterConfiguration();

    String consumerKey = config.getConsumerKey();
    String consumerSecret = config.getConsumerSecret();
    String accessToken = config.getAccessToken();
    String accessTokenSecret = config.getAccessTokenSecret();
    userToSearch = config.getUserToSearch();
    maxTweets = config.getMaxTweets();

    logger.info("Maximum Number of Tweets to extract: " + maxTweets);

    if (consumerKey == null || consumerSecret == null || accessToken == null || accessTokenSecret == null) {
        logger.error("Twitter API Keys have not been set properly in twitterConfig.xml");
        throw new NullPointerException("TWitter API Keys not set");
    }

    cb.setDebugEnabled(true).setOAuthConsumerKey(consumerKey).setOAuthConsumerSecret(consumerSecret)
            .setOAuthAccessToken(accessToken).setOAuthAccessTokenSecret(accessTokenSecret);
}