本文整理汇总了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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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++;
}
}
示例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)));
}
示例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);
}
示例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);
}
示例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;
}
}
示例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());
}
示例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());
}
示例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));
}
示例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_;
}
示例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);
}
}
示例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;
}