ihsanbal / LoggingInterceptor

An OkHttp interceptor which has pretty logger for request and response. +Mock support
MIT License
1.33k stars 112 forks source link

Log both Headers AND Body? #8

Closed andrewmunn closed 7 years ago

andrewmunn commented 7 years ago

Is there a way to log both the headers and body of requests and responses? Seems like it's one or the other right now.

I guess I could just add two loggers?

ihsanbal commented 7 years ago
client.addInterceptor(new LoggingInterceptor.Builder()
                .loggable(BuildConfig.DEBUG)
                .setLevel(Level.BASIC) // Basic Level
                .log(Log.DEBUG)
                .request("Request")
                .response("Response")
                .build());

Level.BASIC log both the your endpoint url with query params, request method, headers and body of request and response.

 - URL
 - Method
 - Headers
 - Body
kevinvanmierlo commented 7 years ago

@ihsanbal Maybe add some info about it in your readme. I would not expect BASIC to log everything. Great library by the way!