<commit_before>package za.org.grassroot.webapp.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by paballo on 2016/03/17.
 */
@Slf4j
public class SimpleLoggingInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        log.info("Handling request, IP appears as: {}", request.getRemoteAddr());
        long startTime = System.currentTimeMillis();
        request.setAttribute("startTime", startTime);
        return true;
    }

    @Override
    public void postHandle(
            HttpServletRequest request, HttpServletResponse response,
            Object handler, ModelAndView modelAndView)
            throws Exception {

        response.addHeader("X-Grassroot-Logged", "true");

        long startTime = (Long) request.getAttribute("startTime");
        long endTime = System.currentTimeMillis();
        long executeTime = endTime - startTime;

        log.debug("{} ms : [{}]", executeTime, handler);
    }
}<commit_msg>Added further, header logging, to trace IP issue<commit_after>package za.org.grassroot.webapp.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.stream.Collectors;

/**
 * Created by paballo on 2016/03/17.
 */
@Slf4j
public class SimpleLoggingInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
        log.info("Handling request, IP appears as: {}", request.getRemoteAddr());
        List<String> headers = Collections.list(request.getHeaderNames());
        Map<String, String> allHeaders = headers.stream().collect(Collectors.toMap(name -> name, request::getHeader));
        log.info("All headers: {}", allHeaders);
        long startTime = System.currentTimeMillis();
        request.setAttribute("startTime", startTime);
        return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response,
            Object handler, ModelAndView modelAndView) {

        response.addHeader("X-Grassroot-Logged", "true");

        long startTime = (Long) request.getAttribute("startTime");
        long endTime = System.currentTimeMillis();
        long executeTime = endTime - startTime;

        log.debug("{} ms : [{}]", executeTime, handler);
    }
}
{'fraction_non_alphanumeric': 0.10686755430974071, 'fraction_numerical': 0.007708479327259986, 'mean_word_length': 3.9139414802065406, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5017290', 'n_tokens_mistral': 775, 'n_tokens_neox': 763, 'n_words': 172}