Java Code Examples for com.blankj.utilcode.util.LogUtils#d()
The following examples show how to use
com.blankj.utilcode.util.LogUtils#d() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InterceptorUtils.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
/** * 网络缓存拦截器,网络连接时请求服务器,否则从本地缓存中获取 * @return */ public static Interceptor addNetWorkInterceptor(){ Interceptor interceptor = new Interceptor() { @Override public Response intercept(Chain chain) throws IOException { Request request = chain.request(); if (!NetworkUtils.isConnected()) { request = request.newBuilder() .cacheControl(CacheControl.FORCE_CACHE) .build(); LogUtils.d("addNetWorkInterceptor"+ "没有网络链接"); } Response response = chain.proceed(request); if (NetworkUtils.isConnected()) { int maxAge = 0; // 有网络时 设置缓存超时时间0个小时 LogUtils.d("addNetWorkInterceptor"+ "网络已连接,缓存时间为:" + maxAge); response = response.newBuilder() .addHeader("Cache-Control", "public, max-age=" + maxAge) .removeHeader("Pragma")// 清除头信息,因为服务器如果不支持,会返回一些干扰信息,不清除下面无法生效 .build(); } else { int maxStale = Constant.TIME_CACHE; LogUtils.d("addNetWorkInterceptor"+ "网络未连接,缓存时间为:" + maxStale); response = response.newBuilder() .addHeader("Cache-Control", "public, only-if-cached, max-stale=" + maxStale) .removeHeader("Pragma") .build(); } String cookeHeader = response.header("Set-Cookie", ""); LogUtils.e("cookeHeader1-----------"+cookeHeader); return response; } }; return interceptor; }
Example 2
Source File: UtilsApp.java From Android-UtilCode with Apache License 2.0 | 5 votes |
public static void initLog() { LogUtils.Builder builder = new LogUtils.Builder() .setLogSwitch(BuildConfig.DEBUG)// 设置log总开关,包括输出到控制台和文件,默认开 .setConsoleSwitch(BuildConfig.DEBUG)// 设置是否输出到控制台开关,默认开 .setGlobalTag(null)// 设置log全局标签,默认为空 // 当全局标签不为空时,我们输出的log全部为该tag, // 为空时,如果传入的tag为空那就显示类名,否则显示tag .setLogHeadSwitch(true)// 设置log头信息开关,默认为开 .setLog2FileSwitch(false)// 打印log时是否存到文件的开关,默认关 .setDir("")// 当自定义路径为空时,写入应用的/cache/log/目录中 .setBorderSwitch(true)// 输出日志是否带边框开关,默认开 .setConsoleFilter(LogUtils.V)// log的控制台过滤器,和logcat过滤器同理,默认Verbose .setFileFilter(LogUtils.V);// log文件过滤器,和logcat过滤器同理,默认Verbose LogUtils.d(builder.toString()); }
Example 3
Source File: LogActivity.java From Android-UtilCode with Apache License 2.0 | 5 votes |
@Override public void run() { LogUtils.v("verbose"); LogUtils.d("debug"); LogUtils.i("info"); LogUtils.w("warn"); LogUtils.e("error"); LogUtils.a("assert"); }
Example 4
Source File: KeyboardActivity.java From Android-UtilCode with Apache License 2.0 | 5 votes |
private boolean isKeyboardShown(View rootView) { final int softKeyboardHeight = 100; Rect frame = new Rect(); rootView.getWindowVisibleDisplayFrame(frame); DisplayMetrics dm = rootView.getResources().getDisplayMetrics(); int heightDiff = rootView.getBottom() - frame.bottom; LogUtils.d("" + rootView.getBottom() + ", " + frame.bottom + ", " + heightDiff); return heightDiff > softKeyboardHeight * dm.density; }
Example 5
Source File: PswActivity.java From ClockView with Apache License 2.0 | 5 votes |
@Override public void onPermissionsGranted(int requestCode, List<String> perms) { LogUtils.d("onPermissionsGranted:" + requestCode + ":" + perms.size()); if (hasAllNeededPermissions()) { // launch(); Toast.makeText(this, "权限已获取,请安心使用!", Toast.LENGTH_SHORT).show(); } }
Example 6
Source File: SimpleLog.java From DanDanPlayForAndroid with MIT License | 4 votes |
public static void d(String tag, String text) { if (loggingEnabled) { LogUtils.d(tag, text); } }
Example 7
Source File: SimpleLog.java From DanDanPlayForAndroid with MIT License | 4 votes |
public static void d(String tag, String text, Throwable e) { if (loggingEnabled) { LogUtils.d(tag, text, e); } }
Example 8
Source File: Demo2Fragment.java From Android-UtilCode with Apache License 2.0 | 4 votes |
@Override public boolean onBackClick() { LogUtils.d("demo2 onBackClick"); return false; }
Example 9
Source File: LogActivity.java From Android-UtilCode with Apache License 2.0 | 4 votes |
@Override public void onWidgetClick(View view) { switch (view.getId()) { case R.id.btn_toggle_log: updateAbout(UPDATE_LOG); break; case R.id.btn_toggle_console: updateAbout(UPDATE_CONSOLE); break; case R.id.btn_toggle_tag: updateAbout(UPDATE_TAG); break; case R.id.btn_toggle_head: updateAbout(UPDATE_HEAD); break; case R.id.btn_toggle_file: updateAbout(UPDATE_FILE); break; case R.id.btn_toggle_dir: updateAbout(UPDATE_DIR); break; case R.id.btn_toggle_border: updateAbout(UPDATE_BORDER); break; case R.id.btn_toggle_conole_filter: updateAbout(UPDATE_CONSOLE_FILTER); break; case R.id.btn_toggle_file_filter: updateAbout(UPDATE_FILE_FILTER); break; case R.id.btn_log_no_tag: LogUtils.v("verbose"); LogUtils.d("debug"); LogUtils.i("info"); LogUtils.w("warn"); LogUtils.e("error"); LogUtils.a("assert"); break; case R.id.btn_log_with_tag: LogUtils.v("customTag", "verbose"); LogUtils.d("customTag", "debug"); LogUtils.i("customTag", "info"); LogUtils.w("customTag", "warn"); LogUtils.e("customTag", "error"); LogUtils.a("customTag", "assert"); break; case R.id.btn_log_in_new_thread: Thread thread = new Thread(mRunnable); thread.start(); break; case R.id.btn_log_null: LogUtils.v(null); LogUtils.d(null); LogUtils.i(null); LogUtils.w(null); LogUtils.e(null); LogUtils.a(null); break; case R.id.btn_log_many_params: LogUtils.v("customTag", "verbose0", "verbose1"); LogUtils.d("customTag", "debug0", "debug1"); LogUtils.i("customTag", "info0", "info1"); LogUtils.w("customTag", "warn0", "warn1"); LogUtils.e("customTag", "error0", "error1"); LogUtils.a("customTag", "assert0", "assert1"); break; case R.id.btn_log_long: LogUtils.d(longStr); break; case R.id.btn_log_file: for (int i = 0; i < 100; i++) { LogUtils.file("test0 log to file"); LogUtils.file(LogUtils.I, "test0 log to file"); } break; case R.id.btn_log_json: String json = "{\"tools\": [{ \"name\":\"css format\" , \"site\":\"http://tools.w3cschool.cn/code/css\" },{ \"name\":\"json format\" , \"site\":\"http://tools.w3cschool.cn/code/json\" },{ \"name\":\"pwd check\" , \"site\":\"http://tools.w3cschool.cn/password/my_password_safe\" }]}"; LogUtils.json(json); LogUtils.json(LogUtils.I, json); break; case R.id.btn_log_xml: String xml = "<books><book><author>Jack Herrington</author><title>PHP Hacks</title><publisher>O'Reilly</publisher></book><book><author>Jack Herrington</author><title>Podcasting Hacks</title><publisher>O'Reilly</publisher></book></books>"; LogUtils.xml(xml); LogUtils.xml(LogUtils.I, xml); break; } }