Curl-Logger-interceptor

Additional

Language
Java
Version
N/A
Created
Jun 14, 2016
Updated
Jul 16, 2016 (Retired)
Owner
Grapes 'n' Berries (grapesnberries)
Contributors
Mohamed Zakaria El-Zoghbi (mzelzoghbi)
HeshamMegid
2
Activity
Badge
Generate
Download
Source code
APK file

Promotion

Curl-Logger-interceptor

A library that logs your request in cURL, used with Retrofit HTTP client.

How it works

Add the library in your build.gradle app level file

dependencies {
    ...
    compile 'com.github.grapesnberries:curlloggerinterceptor:0.1'
    
}

To start logging your requests, add a cURL interceptor to your OkHttpClient

OkHttpClient.Builder client = new OkHttpClient.Builder()
                // add our curl logger here
                .addInterceptor(new CurlLoggerInterceptor());
                
        Retrofit retrofit = new Retrofit.Builder()
                ...
                .client(client.build())
                .build();

Yes you are done! Once you make any request you will find the output Curl command in you logcat like that

Customized Log Tag

You can customize you logcat like that

private final String TAG = "USER_TAG"

...

OkHttpClient.Builder client = new OkHttpClient.Builder()
                // add our curl logger here
                .addInterceptor(new CurlLoggerInterceptor(TAG));


License

Copyright 2016 Grapes 'n' Berries

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.