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


Java LogLevel类代码示例

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


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

示例1: getRealTokenService

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
/**
 * Return a instance of tokenService to call it
 * 
 * @param authority
 * @return TokenService return a proxy to call api
 */
private static TokenService getRealTokenService(String authority) {
	// Create a logging interceptor to log request and responses
	OkHttpClient client = new OkHttpClient();
	InetSocketAddress p = findProxy();
	if(p != null) {
		client.setProxy(new Proxy(Proxy.Type.HTTP,p));
	} else { 
		client.setProxy(Proxy.NO_PROXY); 
	}
	// Create and configure the Retrofit object
	RestAdapter retrofit = new RestAdapter.Builder().setEndpoint(authority)
			.setLogLevel(LogLevel.FULL).setLog(new RestAdapter.Log() {
				@Override
				public void log(String msg) {
					logger.debug(msg);
				}
			}).setClient(new OkClient(client)).build();

	// Generate the token service
	return retrofit.create(TokenService.class);
}
 
开发者ID:OwaNotifier,项目名称:owa-notifier,代码行数:28,代码来源:RestfullAcessProxy.java

示例2: RestClientContextEntity

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
public RestClientContextEntity() {
	super(service);
	
	if (android.os.Build.MODEL.contains("google_sdk") ||
		    android.os.Build.MODEL.contains("Emulator")) {
		// emulator
		restAdapter = new RestAdapter.Builder()
		.setEndpoint(endPointEmulator)
		.setLogLevel(LogLevel.FULL)
		.build();
	} else {
		//not emulator
		restAdapter = new RestAdapter.Builder()
		.setEndpoint(endPointPhone)
		.setLogLevel(LogLevel.FULL)
		.build();
	}
	
	this.magpieSvc = restAdapter.create(MagpieSvcApi.class);
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:21,代码来源:RestClientContextEntity.java

示例3: testRedirectToLoginWithoutAuth

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
/**
 * This test creates a Video and attempts to add it to the video service
 * without logging in. The test checks to make sure that the request is
 * denied and the client redirected to the login page.
 * 
 * @throws Exception
 */
@Test
public void testRedirectToLoginWithoutAuth() throws Exception {
	ErrorRecorder error = new ErrorRecorder();

	VideoSvcApi videoService = new RestAdapter.Builder()
			.setClient(
					new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
			.setEndpoint(TEST_URL).setLogLevel(LogLevel.FULL)
			.setErrorHandler(error).build().create(VideoSvcApi.class);
	try {
		// This should fail because we haven't logged in!
		videoService.addVideo(video);

		fail("Yikes, the security setup is horribly broken and didn't require the user to login!!");

	} catch (Exception e) {
		// Ok, our security may have worked, ensure that
		// we got redirected to the login page
		assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, error.getError()
				.getResponse().getStatus());
	}
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:30,代码来源:VideoSvcClientApiTest.java

示例4: initializeApiClient

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
private void initializeApiClient() throws RetrofitError {
    ApiClient apiClient = new ApiClient();

    OAuth auth = new OAuth(new TrustingOkHttpClient(),
            OAuthClientRequest.tokenLocation("https://api.netatmo.net/oauth2/token"));
    auth.setFlow(OAuthFlow.password);
    auth.setAuthenticationRequestBuilder(OAuthClientRequest.authorizationLocation(""));

    apiClient.getApiAuthorizations().put("password_oauth", auth);
    apiClient.getTokenEndPoint().setClientId(configuration.clientId).setClientSecret(configuration.clientSecret)
            .setUsername(configuration.username).setPassword(configuration.password).setScope(getApiScope());

    apiClient.configureFromOkclient(new TrustingOkHttpClient());
    apiClient.getAdapterBuilder().setLogLevel(logger.isDebugEnabled() ? LogLevel.FULL : LogLevel.NONE);

    apiMap = new APIMap(apiClient);
}
 
开发者ID:openhab,项目名称:openhab2-addons,代码行数:18,代码来源:NetatmoBridgeHandler.java

示例5: main

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
public static void main(String[] args) {
	RestAdapter restAdapter = new RestAdapter.Builder()
			.setServer("http://gdata.youtube.com")
			.setConverter(new SimpleXMLConverter())
			.build();
	restAdapter.setLogLevel(LogLevel.FULL);
	YouTubeDataService service = restAdapter
			.create(YouTubeDataService.class);

	if (args == null || args.length < 1) {
		usage();
		return;
	}

	String query = args[0];
	Feed result = service.search(query, "published", 1);
	System.out.printf("検索キーワード:%s\n", query);
	System.out.printf("%s件中%s件〜%s件目を表示\n", result.totalResults,
			result.startIndex,
			(result.startIndex + result.itemsPerPage - 1));
	int i = 1;
	for (Entry entry : result.entries) {
		System.out.printf("%d: %s: %s\n", i, entry.title, entry.getHtmlLocation());
		i++;
	}
}
 
开发者ID:tsuyosh,项目名称:RetrofitExamples,代码行数:27,代码来源:Main.java

示例6: buildCommonRestAdapterBuilder

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
private RestAdapter.Builder buildCommonRestAdapterBuilder(Gson gson, OkHttpClient client) {
    return new RestAdapter.Builder()
            .setClient(new OkClient(client))
            .setConverter(new GsonConverter(gson))
            .setEndpoint(getApiUri().toString())
            .setLogLevel(LogLevel.valueOf(ctx.getString(R.string.http_log_level)));
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:8,代码来源:ApiFactory.java

示例7: setup

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
@Before
public void setup() {
    mCountDownLatch = new CountDownLatch(1);
    mApiClient = new RestAdapter.Builder()
            .setEndpoint(Settings.getSandboxUrl())
            .setRequestInterceptor(new ApiClientRequestInterceptor())
            .setLogLevel(LogLevel.FULL)
            .build()
            .create(ApiClient.class);
}
 
开发者ID:braintree,项目名称:braintree-android-drop-in,代码行数:11,代码来源:ApiClientUnitTest.java

示例8: getService

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
public static WikiService getService() {
    RestAdapter restAdapter = new RestAdapter.Builder()
            .setEndpoint("https://wiki.zhenguanyu.com")
            .setLogLevel(LogLevel.BASIC)
            .setClient(new OkClient(MySSLTrust.trustcert(MyApplication.getInstance())))
            .setConverter(new MyGsonConvertor(new Gson()))
            .build();
    return restAdapter.create(WikiService.class);
}
 
开发者ID:bwzz,项目名称:yyl,代码行数:10,代码来源:WikiAdapter.java

示例9: setVerboseLoggingEnabled

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
/**
 * Enabled/Disables full logging of retrofit REST calls.
 *
 * @param enabled
 *           if <code>true</code> sets retrofit's log level to {@link LogLevel#FULL}
 */
public void setVerboseLoggingEnabled(boolean enabled) {
   if (enabled) {
      restAdapter.setLogLevel(LogLevel.FULL);
      prettyJson = true;
   } else {
      prettyJson = false;
   }
}
 
开发者ID:kaiwinter,项目名称:rhapsody-java-sdk,代码行数:15,代码来源:RhapsodySdkWrapper.java

示例10: SessionBaseService

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
public SessionBaseService(Context context) {
	final RestAdapter restAdapter = new RestAdapter.Builder()
			.setEndpoint(Constants.SESSION_SATOSHI_DICE)
			.setClient(new OkClient(getUnsafeOkHttpClient()))
			.setConverter(new JacksonConverter()).build();
	if (Constants.LOG_LEVEL_FULL) {
		restAdapter.setLogLevel(LogLevel.FULL);
	}
	mRestService = restAdapter.create(getClazz());
}
 
开发者ID:skubit,项目名称:skubit-satoshidice,代码行数:11,代码来源:SessionBaseService.java

示例11: BaseService

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
public BaseService(Context context) {
	final RestAdapter restAdapter = new RestAdapter.Builder()
			.setEndpoint(Constants.SATOSHI_DICE)
			.setConverter(new JacksonConverter()).build();
	if (Constants.LOG_LEVEL_FULL) {
		restAdapter.setLogLevel(LogLevel.FULL);
	}
	mRestService = restAdapter.create(getClazz());
}
 
开发者ID:skubit,项目名称:skubit-satoshidice,代码行数:10,代码来源:BaseService.java

示例12: testDenyVideoAddWithoutLogin

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
/**
 * This test creates a Video and attempts to add it to the video service
 * without logging in. The test checks to make sure that the request is
 * denied and the client redirected to the login page.
 * 
 * @throws Exception
 */
@Test
public void testDenyVideoAddWithoutLogin() throws Exception {
	ErrorRecorder error = new ErrorRecorder();

	VideoSvcApi videoService = new RestAdapter.Builder()
			.setClient(
					new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
			.setEndpoint(TEST_URL).setLogLevel(LogLevel.FULL)
			.setErrorHandler(error).build().create(VideoSvcApi.class);
	try {
		// This should fail because we haven't logged in!
		videoService.addVideo(video);

		fail("Yikes, the security setup is horribly broken and didn't require the user to login!!");

	} catch (Exception e) {
		// Ok, our security may have worked, ensure that
		// we got redirected to the login page
		assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, error.getError()
				.getResponse().getStatus());
	}

	// Now, let's login and ensure that the Video wasn't added
	videoService.login("coursera", "changeit");
	
	// We should NOT get back the video that we added above!
	Collection<Video> videos = videoService.getVideoList();
	assertFalse(videos.contains(video));
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:37,代码来源:VideoSvcClientApiTest.java

示例13: init

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
public static synchronized VideoSvcApi init(String server, String user,
		String pass) {

	videoSvc_ = new SecuredRestBuilder()
			.setLoginEndpoint(server + VideoSvcApi.TOKEN_PATH)
			.setUsername(user)
			.setPassword(pass)
			.setClientId(CLIENT_ID)
			.setClient(
					new ApacheClient(new EasyHttpClient()))
			.setEndpoint(server).setLogLevel(LogLevel.FULL).build()
			.create(VideoSvcApi.class);

	return videoSvc_;
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:16,代码来源:VideoSvc.java

示例14: onConfiguration

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
/**
 * Hook method dispatched by the GenericActivity framework to
 * initialize the AcronymOps object after it's been created.
 *
 * @param view         The currently active AcronymOps.View.
 * @param firstTimeIn  Set to "true" if this is the first time the
 *                     Ops class is initialized, else set to
 *                     "false" if called after a runtime
 *                     configuration change.
 */
public void onConfiguration(AcronymOps.View view,
                            boolean firstTimeIn) {
    Log.d(TAG,
          "onConfiguration() called");

    // Reset the mAcronymView WeakReference.
    mAcronymView =
        new WeakReference<>(view);

    if (firstTimeIn) {
        // Store the Application context to avoid problems with
        // the Activity context disappearing during a rotation.
        mContext = view.getApplicationContext();
    
        // Set up the HttpResponse cache that will be used by
        // Retrofit.
        mCache = new Cache(new File(mContext.getCacheDir(),
                                    CACHE_FILENAME),
                           // Cache stores up to 1 MB.
                           1024 * 1024); 
    
        // Set up the client that will use this cache.  Retrofit
        // will use okhttp client to make network calls.
        mOkHttpClient = new OkHttpClient();  
        if (mCache != null) 
            mOkHttpClient.setCache(mCache);

        // Create a proxy to access the Acronym Service web
        // service.
        mAcronymWebServiceProxy =
            new RestAdapter.Builder()
            .setEndpoint(AcronymWebServiceProxy.ENDPOINT)
            .setClient(new OkClient(mOkHttpClient))
            // .setLogLevel(LogLevel.FULL)
            .setLogLevel(LogLevel.NONE)
            .build()
            .create(AcronymWebServiceProxy.class);
    } 
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:50,代码来源:AcronymOps.java

示例15: getRequest

import retrofit.RestAdapter.LogLevel; //导入依赖的package包/类
private Request getRequest() {
	String servidor = END_POINT;
	if(customIp != null){
		servidor = "http://"+customIp;
		if(customPort != null)
			servidor += ":"+customPort;
	}
	RestAdapter restAdapter = new RestAdapter.Builder()
	.setEndpoint(servidor)
	.setLogLevel(LogLevel.FULL)
	.build();
	
	Request rsqt = restAdapter.create(Request.class);
	return rsqt;
}
 
开发者ID:leofarage,项目名称:ckl-challenge,代码行数:16,代码来源:JSONRequest.java


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