Package net.sourceforge.pebble.logging

Examples of net.sourceforge.pebble.logging.Log


   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    Set<String> countries = new TreeSet<String>(new Comparator<String>() {
      public int compare(String s1, String s2) {
        return s1 != null ? s1.compareToIgnoreCase(s2) : -1;
      }
    });
    Map<String,Integer> consolidatedCountries = new HashMap<String,Integer>();
    Map<String,Integer> countriesForNewsFeeds = new HashMap<String,Integer>();
    Map<String,Integer> countriesForPageViews = new HashMap<String,Integer>();
    Map<String,Integer> countriesForFileDownloads = new HashMap<String,Integer>();

    LookupService lookupService = null;

    try {
      String filename = getClass().getResource("/geo-ip.dat").toExternalForm().substring(5);
      lookupService = new LookupService(filename, LookupService.GEOIP_MEMORY_CACHE);

      for (LogEntry logEntry : log.getLogEntries()) {
        String country = lookupService.getCountry(logEntry.getHost()).getName();
        countries.add(country);
        register(country, countriesForNewsFeeds);
        register(country, countriesForPageViews);
        register(country, countriesForFileDownloads);
View Full Code Here


    String yearAsString = request.getParameter("year");
    String monthAsString = request.getParameter("month");
    String dayAsString = request.getParameter("day");

    Calendar cal = blog.getCalendar();
    Log log = null;
    String logPeriod = "";

    if (yearAsString != null && yearAsString.length() > 0 &&
        monthAsString != null && monthAsString.length() > 0 &&
        dayAsString != null && dayAsString.length() > 0) {
View Full Code Here

  /**
   * Prepares the view for presentation.
   */
  public void prepare() {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = (Log)getModel().get("log");
    StringBuffer buf = new StringBuffer();
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMMM-yyyy HH:mm:ss Z");
    sdf.setTimeZone(blog.getTimeZone());

    buf.append("Host");
    buf.append(SEPARATOR);
    buf.append("Date/Time");
    buf.append(SEPARATOR);
    buf.append("Method");
    buf.append(SEPARATOR);
    buf.append("Request URI");
    buf.append(SEPARATOR);
    buf.append("Status");
    buf.append(SEPARATOR);
    buf.append("Referer");
    buf.append(SEPARATOR);
    buf.append("User-Agent");
    buf.append("\n");
   
    if (log != null) {
      for (LogEntry logEntry : log.getLogEntries()) {
        buf.append(logEntry.getHost());
        buf.append(SEPARATOR);
        buf.append(sdf.format(logEntry.getDate()));
        buf.append(SEPARATOR);
        buf.append(logEntry.getRequestMethod());
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    List requests = new ArrayList(log.getRequests());

    String sort = request.getParameter("sort");
    if (sort == null || sort.trim().equals("")) {
      sort = "rank";
    }
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    // work out requests per hour
    int[] requestsPerHour = new int[24];
    Set<String>[] uniqueIpsPerHourAsSet = new Set[24];
    for (int hour = 0; hour < 24; hour++) {
      requestsPerHour[hour] = 0;
      uniqueIpsPerHourAsSet[hour] = new HashSet<String>();
    }
    for (LogEntry logEntry : log.getLogEntries()) {
      Calendar logTime = blog.getCalendar();
      logTime.setTime(logEntry.getDate());
      int hour = logTime.get(Calendar.HOUR_OF_DAY);
      requestsPerHour[hour] = requestsPerHour[hour]+1;
      uniqueIpsPerHourAsSet[hour].add(logEntry.getHost());

      if (logEntry.getRequestUri() != null &&
          logEntry.getRequestUri().indexOf("rss.xml") > -1 ||
          logEntry.getRequestUri().indexOf("feed.xml") > -1 ||
          logEntry.getRequestUri().indexOf("feed.action") > -1 ||
          logEntry.getRequestUri().indexOf("rdf.xml") > -1 ||
          logEntry.getRequestUri().indexOf("atom.xml") > -1) {
      }
    }

    int[] uniqueIpsPerHour = new int[24];
    for (int hour = 0; hour < 24; hour++) {
      uniqueIpsPerHour[hour] = uniqueIpsPerHourAsSet[hour].size();
    }

    getModel().put("logAction", "viewRequestsByHour");
    getModel().put("totalRequests", log.getTotalLogEntries());
    getModel().put("requestsPerHour", requestsPerHour);
    getModel().put("uniqueIpsPerHour", uniqueIpsPerHour);

    return new RequestsByHourView();
  }
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    Map<String, Integer> userAgents = new TreeMap<String, Integer>(new Comparator<String>() {
      public int compare(String s1, String s2) {
        return s1 != null ? s1.compareToIgnoreCase(s2) : -1;
      }
    });

    Map<String, Integer> consolidatedUserAgents = new TreeMap<String, Integer>(new Comparator<String>() {
      public int compare(String s1, String s2) {
        return s1 != null ? s1.compareToIgnoreCase(s2) : -1;
      }
    });

    for (LogEntry logEntry : log.getLogEntries()) {
      String userAgent = logEntry.getAgent();
      if (userAgent == null) {
        userAgent = "";
      }

View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    Collection<Request> requests = log.getRequests();
    Set<String> uniqueIps = new HashSet<String>();
    Set<String> uniqueIpsForNewsFeeds = new HashSet<String>();
    Set<String> uniqueIpsForPageViews = new HashSet<String>();
    Set<String> uniqueIpsForFileDownloads = new HashSet<String>();
    int totalNewsFeedRequests = 0;
    int totalPageViews = 0;
    int totalFileDownloads = 0;

    for (Request aRequest : requests) {
      for (LogEntry logEntry : aRequest.getLogEntries()) {
        uniqueIps.add(logEntry.getHost());
      }

      if (aRequest.isNewsFeed()) {
        totalNewsFeedRequests += aRequest.getCount();
        for (LogEntry logEntry : aRequest.getLogEntries()) {
          uniqueIpsForNewsFeeds.add(logEntry.getHost());
        }
      } else if (aRequest.isPageView()) {
        totalPageViews += aRequest.getCount();
        for (LogEntry logEntry : aRequest.getLogEntries()) {
          uniqueIpsForPageViews.add(logEntry.getHost());
        }
      } else if (aRequest.isFileDownload()) {
        totalFileDownloads += aRequest.getCount();
        for (LogEntry logEntry : aRequest.getLogEntries()) {
          uniqueIpsForFileDownloads.add(logEntry.getHost());
        }
      }
    }

    getModel().put("logAction", "viewRequestsByType");
    getModel().put("totalRequests", log.getTotalLogEntries());
    getModel().put("uniqueIps", uniqueIps.size());
    getModel().put("totalNewsfeedRequests", totalNewsFeedRequests);
    getModel().put("uniqueIpsForNewsFeeds", uniqueIpsForNewsFeeds.size());
    getModel().put("totalPageViews", totalPageViews);
    getModel().put("uniqueIpsForPageViews", uniqueIpsForPageViews.size());
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    String filter = request.getParameter("filter");
    List referers = new ArrayList(log.getReferers());
    if (filter == null || filter.equalsIgnoreCase("true")) {
      referers = blog.getRefererFilterManager().filter(referers);
    }
    Collections.sort(referers, new CountedUrlByCountComparator());

View Full Code Here

   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    String flavor = request.getParameter("flavor");

    if (flavor != null && flavor.equalsIgnoreCase("tab")) {
      Log log = getLog(request, response);
      getModel().put("log", log);
      return new LogAsTabDelimitedView();
    } else {
      String log = getLogFile(request, response);
      getModel().put("text", log);
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.logging.Log

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.