当前位置: 首页>>代码示例>>Java>>正文


Java LoggingInterceptor类代码示例

本文整理汇总了Java中com.microsoft.rest.interceptors.LoggingInterceptor的典型用法代码示例。如果您正苦于以下问题:Java LoggingInterceptor类的具体用法?Java LoggingInterceptor怎么用?Java LoggingInterceptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LoggingInterceptor类属于com.microsoft.rest.interceptors包,在下文中一共展示了LoggingInterceptor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: Builder

import com.microsoft.rest.interceptors.LoggingInterceptor; //导入依赖的package包/类
/**
 * Creates an instance of the builder with a base URL and 2 custom builders.
 *
 * @param httpClientBuilder the builder to build an {@link OkHttpClient}.
 * @param retrofitBuilder the builder to build a {@link Retrofit}.
 */
public Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofitBuilder) {
    if (httpClientBuilder == null) {
        throw new IllegalArgumentException("httpClientBuilder == null");
    }
    if (retrofitBuilder == null) {
        throw new IllegalArgumentException("retrofitBuilder == null");
    }
    CookieManager cookieManager = new CookieManager();
    cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
    customHeadersInterceptor = new CustomHeadersInterceptor();
    // Set up OkHttp client
    this.httpClientBuilder = httpClientBuilder
            .cookieJar(new JavaNetCookieJar(cookieManager))
            .readTimeout(60, TimeUnit.SECONDS)
            .addInterceptor(new RequestIdHeaderInterceptor())
            .addInterceptor(new BaseUrlHandler());
    this.retrofitBuilder = retrofitBuilder;
    this.loggingInterceptor = new LoggingInterceptor(LogLevel.NONE);
}
 
开发者ID:Azure,项目名称:autorest-clientruntime-for-java,代码行数:26,代码来源:RestClient.java

示例2: RefreshTokenClient

import com.microsoft.rest.interceptors.LoggingInterceptor; //导入依赖的package包/类
RefreshTokenClient(String baseUrl, Proxy proxy) {
    OkHttpClient.Builder builder = new OkHttpClient.Builder().addInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS));
    if (proxy != null) {
        builder = builder.proxy(proxy);
    }
    service = new Retrofit.Builder()
            .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
            .addConverterFactory(new JacksonAdapter().converterFactory())
            .baseUrl(baseUrl)
            .client(builder.build())
        .build().create(RefreshTokenService.class);
}
 
开发者ID:Azure,项目名称:autorest-clientruntime-for-java,代码行数:13,代码来源:RefreshTokenClient.java

示例3: beforeTest

import com.microsoft.rest.interceptors.LoggingInterceptor; //导入依赖的package包/类
@Before
public void beforeTest() throws IOException {
    printThreadInfo(String.format("%s: %s", "beforeTest", testName.getMethodName()));
    final String skipMessage = shouldCancelTest(isPlaybackMode());
    Assume.assumeTrue(skipMessage, skipMessage == null);

    interceptorManager = InterceptorManager.create(testName.getMethodName(), testMode);

    ApplicationTokenCredentials credentials;
    RestClient restClient;
    String defaultSubscription;

    if (isPlaybackMode()) {
        credentials = new AzureTestCredentials(playbackUri, ZERO_TENANT, true);
        restClient = buildRestClient(new RestClient.Builder()
                .withBaseUrl(playbackUri + "/")
                .withSerializerAdapter(new AzureJacksonAdapter())
                .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
                .withCredentials(credentials)
                .withLogLevel(LogLevel.NONE)
                .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS))
                .withNetworkInterceptor(interceptorManager.initInterceptor())
                .withInterceptor(new ResourceManagerThrottlingInterceptor())
                ,true);

        defaultSubscription = ZERO_SUBSCRIPTION;
        System.out.println(playbackUri);
        out = System.out;
        System.setOut(new PrintStream(new OutputStream() {
            public void write(int b) {
                //DO NOTHING
            }
        }));
    }
    else { // Record mode
        final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
        credentials = ApplicationTokenCredentials.fromFile(credFile);
        restClient = buildRestClient(new RestClient.Builder()
                .withBaseUrl(this.baseUri())
                .withSerializerAdapter(new AzureJacksonAdapter())
                .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
                .withInterceptor(new ProviderRegistrationInterceptor(credentials))
                .withCredentials(credentials)
                .withLogLevel(LogLevel.NONE)
                .withReadTimeout(3, TimeUnit.MINUTES)
                .withNetworkInterceptor(new LoggingInterceptor(LogLevel.BODY_AND_HEADERS))
                .withNetworkInterceptor(interceptorManager.initInterceptor())
                .withInterceptor(new ResourceManagerThrottlingInterceptor())
                ,false);

        defaultSubscription = credentials.defaultSubscriptionId();
        interceptorManager.addTextReplacementRule(defaultSubscription, ZERO_SUBSCRIPTION);
        interceptorManager.addTextReplacementRule(credentials.domain(), ZERO_TENANT);
        interceptorManager.addTextReplacementRule(baseUri(), playbackUri + "/");
        interceptorManager.addTextReplacementRule("https://graph.windows.net/", playbackUri + "/");
    }
    initializeClients(restClient, defaultSubscription, credentials.domain());
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:59,代码来源:TestBase.java


注:本文中的com.microsoft.rest.interceptors.LoggingInterceptor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。