xLog icon indicating copy to clipboard operation
xLog copied to clipboard

Please provide examples for API Requests and Responses

Open spragucm opened this issue 5 years ago • 1 comments

The only reason I found this library and tried to use it was in order to nicely display API Requests and Responses as shown on your main page.

Yet, there is no example showing how to do this :(

Can you please provide a quick example of how you achieved a nice log message for both situations?

Many thanks, Chris

spragucm avatar Apr 04 '20 22:04 spragucm

@spragucm You can take a look at HttpLoggingInterceptor of okhttp, customize a HttpLoggingInterceptor.Logger and use xLog to print the API response by calling

XLog.d(
    LogUtil.addBorder(
        new String[] {
            "<request type>",
            "<request url>",
            "<http status>",
            "<response body>"
        }))

Then you will see the similar result as the screenshot

elvishew avatar Oct 23 '20 11:10 elvishew