mirror of
https://github.com/czp3009/bilibili-api.git
synced 2025-02-19 20:50:28 +08:00
自定义 HttpLogger 等级
This commit is contained in:
parent
91fd0d23b9
commit
b294568710
@ -65,13 +65,15 @@ public class BilibiliAPI implements BilibiliServiceProvider, LiveClientProvider
|
||||
@Override
|
||||
public PassportService getPassportService() {
|
||||
if (passportService == null) {
|
||||
passportService = getPassportServiceWithCustomInterceptors(Collections.emptyList());
|
||||
passportService = getPassportService(Collections.emptyList(), HttpLoggingInterceptor.Level.BASIC);
|
||||
}
|
||||
return passportService;
|
||||
}
|
||||
|
||||
public PassportService getPassportServiceWithCustomInterceptors(@Nonnull List<Interceptor> interceptors) {
|
||||
public PassportService getPassportService(@Nonnull List<Interceptor> interceptors, @Nonnull HttpLoggingInterceptor.Level logLevel) {
|
||||
Objects.requireNonNull(interceptors);
|
||||
Objects.requireNonNull(logLevel);
|
||||
|
||||
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
|
||||
|
||||
interceptors.forEach(okHttpClientBuilder::addInterceptor);
|
||||
@ -88,7 +90,7 @@ public class BilibiliAPI implements BilibiliServiceProvider, LiveClientProvider
|
||||
.addInterceptor(new AddAppKeyInterceptor(bilibiliClientProperties))
|
||||
.addInterceptor(new SortParamsAndSignInterceptor(bilibiliClientProperties))
|
||||
.addInterceptor(new ErrorResponseConverterInterceptor())
|
||||
.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC));
|
||||
.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(logLevel));
|
||||
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(BaseUrlDefinition.PASSPORT)
|
||||
@ -101,13 +103,15 @@ public class BilibiliAPI implements BilibiliServiceProvider, LiveClientProvider
|
||||
@Override
|
||||
public LiveService getLiveService() {
|
||||
if (liveService == null) {
|
||||
liveService = getLiveServiceWithCustomInterceptors(Collections.emptyList());
|
||||
liveService = getLiveService(Collections.emptyList(), HttpLoggingInterceptor.Level.BASIC);
|
||||
}
|
||||
return liveService;
|
||||
}
|
||||
|
||||
public LiveService getLiveServiceWithCustomInterceptors(@Nonnull List<Interceptor> interceptors) {
|
||||
public LiveService getLiveService(@Nonnull List<Interceptor> interceptors, @Nonnull HttpLoggingInterceptor.Level logLevel) {
|
||||
Objects.requireNonNull(interceptors);
|
||||
Objects.requireNonNull(logLevel);
|
||||
|
||||
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder();
|
||||
|
||||
interceptors.forEach(okHttpClientBuilder::addInterceptor);
|
||||
@ -147,7 +151,7 @@ public class BilibiliAPI implements BilibiliServiceProvider, LiveClientProvider
|
||||
.addInterceptor(new AddAccessKeyInterceptor(bilibiliAccount))
|
||||
.addInterceptor(new SortParamsAndSignInterceptor(bilibiliClientProperties))
|
||||
.addInterceptor(new ErrorResponseConverterInterceptor())
|
||||
.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BASIC));
|
||||
.addNetworkInterceptor(new HttpLoggingInterceptor().setLevel(logLevel));
|
||||
|
||||
return new Retrofit.Builder()
|
||||
.baseUrl(BaseUrlDefinition.LIVE)
|
||||
|
@ -164,6 +164,7 @@ public class LiveClient implements Closeable {
|
||||
.body();
|
||||
}
|
||||
|
||||
//TODO 弹幕发送队列
|
||||
// public void sendBulletScreenAsync(@Nonnull String message, @Nonnull BulletScreenSendingCallback bulletScreenSendingCallback, boolean autoSplit) {
|
||||
// if (!autoSplit) {
|
||||
// sendBulletScreenAsync(message, bulletScreenSendingCallback);
|
||||
|
@ -16,10 +16,10 @@ public class SsoTest {
|
||||
@Ignore
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
Object object = BILIBILI_API.getPassportService()
|
||||
.sso(BILIBILI_API.getBilibiliAccount().getAccessToken(), null)
|
||||
.execute()
|
||||
.body();
|
||||
LOGGER.info("{}", object.toString());
|
||||
// Object object = BILIBILI_API.getPassportService()
|
||||
// .sso(BILIBILI_API.getBilibiliAccount().getAccessToken(), null)
|
||||
// .execute()
|
||||
// .body();
|
||||
// LOGGER.info("{}", object.toString());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user