0

In retrofit there is a interface RequestInterceptor which a class can implement and then in the restadapter you can set this to be the setRequestInterceptor. an example from the net would be:

RequestInterceptor requestInterceptor = new RequestInterceptor() {
    @Override
    public void intercept(RequestFacade request) {
        request.addHeader("User-Agent", "Retrofit-Sample-App");
    }
};

RestAdapter restAdapter = new RestAdapter.Builder()
    .setEndpoint("https://api.github.com")
    .setRequestInterceptor(requestInterceptor)
    .build();

Now for what i need help with. I was expecting the interceptor to be able to show me all the requests that are going out. Instead its a fascade and just a few methods are exposed. My end goal in retrofit is to be able to print a log of every call that goes out.

Bryan Herbst
  • 65,094
  • 10
  • 126
  • 115
j2emanue
  • 56,631
  • 57
  • 264
  • 415

1 Answers1

2

You can use the method setLogLevel(LogLevel.FULL) on your RestAdapter instance. This will log all retrofit network log.

Bryan Herbst
  • 65,094
  • 10
  • 126
  • 115
Mimmo Grottoli
  • 5,697
  • 2
  • 15
  • 26
  • actually i wanted to see it from a break point through the request facade. I already knew about the log lol. But anyway i guess thats the only way, thanks. – j2emanue Jul 16 '15 at 20:23
  • 1
    Are you using Retrofit + Okhttp? You can add the interceptor to okhttp. See [this guide](https://github.com/square/okhttp/wiki/Interceptors) – Mimmo Grottoli Jul 17 '15 at 16:49
  • the interceptor on Okhttp is exactly what i wanted.i upvoted you. Excellent. im not sure why someone downvoted me. Its not quite obvious that Okhttp has interceptors. – j2emanue Jul 18 '15 at 15:00
  • @j2emanue this is a community. Accept others and go on. By the way, the upvote on comments are useless :) – Mimmo Grottoli Jul 18 '15 at 18:55