-
Notifications
You must be signed in to change notification settings - Fork 735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add logging of requests and responses #151
Comments
Could you describe what problems do you have? There are some issues when logging wouldn't help you at all. |
I faced with the following problem: github-api works fine if I send requests by portions (~200-1000 for one time), but it works very unstable when I make a lot of requests (~4000) for a short period of time (it hangs or throws strange NPE). It is not critical issue for me, as I said, I just send request by portions, but it will be interesting to know the root of this problem. It looks like (sometimes) Github responds incorrectly and github-api does not process it correctly (or some problems with concurrency). |
Ok, I'll try to reproduce this problems tomorrow. |
When embedding in own tools (like maven/gradle plugin) it could be useful to help diagnose end user problems. |
You should be able to use OkHttp with Logging interceptors: Cache cache = new Cache(new File(cacheDir), cacheMB * 1024 * 1024);
try {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(new HttpLoggingInterceptor.Logger() {
@Override
public void log(String message) {
System.out.println("Intercepted " + message);
}
});
logging.setLevel(HttpLoggingInterceptor.Level.HEADERS);
OkHttpClient.Builder okHttpClient = new OkHttpClient.Builder();
okHttpClient.addInterceptor(logging);
okHttpClient.cache(cache);
gitHub = GitHubBuilder.fromEnvironment().withPassword("", "")
.withConnector(new OkHttp3Connector(new OkUrlFactory(okHttpClient.build())))
.build(); This should, but does not work for me :) |
@rmetzger |
@rmetzger Did you at the end manage to get it right? I have the same working example, and the logging interceptors are not called. |
IIRC I didn't manage to fix this :( @bitwiseman's comment seem to confirm that this is currently not supported. |
@marcin-majewski-sonarsource github-api/src/main/java/org/kohsuke/github/GitHubClient.java Lines 422 to 425 in e66a723
But full logging requires moving to a non- |
Closed by #1290. |
Add possibility to log requests and responses.
It will help to understand a lot of cases when library does not work.
The text was updated successfully, but these errors were encountered: