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


Java LogUtils类代码示例

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


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

示例1: initLog

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
public void initLog() {
    LogUtils.Config config = LogUtils.getConfig()
            .setLogSwitch(BuildConfig.DEBUG)// 设置log总开关,包括输出到控制台和文件,默认开
            .setConsoleSwitch(BuildConfig.DEBUG)// 设置是否输出到控制台开关,默认开
            .setGlobalTag(null)// 设置log全局标签,默认为空
            // 当全局标签不为空时,我们输出的log全部为该tag,
            // 为空时,如果传入的tag为空那就显示类名,否则显示tag
            .setLogHeadSwitch(true)// 设置log头信息开关,默认为开
            .setLog2FileSwitch(false)// 打印log时是否存到文件的开关,默认关
            .setDir("")// 当自定义路径为空时,写入应用的/cache/log/目录中
            .setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-MM-dd.txt"
            .setBorderSwitch(true)// 输出日志是否带边框开关,默认开
            .setConsoleFilter(LogUtils.V)// log的控制台过滤器,和logcat过滤器同理,默认Verbose
            .setFileFilter(LogUtils.V)// log文件过滤器,和logcat过滤器同理,默认Verbose
            .setStackDeep(1);// log栈深度,默认为1
    LogUtils.d(config.toString());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:UtilsApp.java

示例2: initAssets

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
private void initAssets() {
    if (!FileUtils.isFileExists(Config.TEST_APK_PATH)) {
        ThreadPoolUtils poolUtils = new ThreadPoolUtils(ThreadPoolUtils.SingleThread, 1);
        poolUtils.execute(new Runnable() {
            @Override
            public void run() {
                try {
                    FileIOUtils.writeFileFromIS(Config.TEST_APK_PATH, getAssets().open("test_install"), false);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        });
    } else {
        LogUtils.d("test apk existed.");
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:UtilsApp.java

示例3: onError

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
public void onError(@NonNull Throwable e) {
    LoadingDialog.dissmiss();
    String errMsg = "";
    if (e instanceof SocketTimeoutException) {
        errMsg = "网络连接超时,请检查您的网络状态,稍后重试";
    } else if (e instanceof ConnectException) {
        errMsg = "网络连接异常,请检查您的网络状态";
    } else if (e instanceof UnknownHostException) {
        errMsg = "网络异常,请检查您的网络状态";
    } else {
        errMsg = e.getMessage();
    }
    LogUtils.i("onError:" + errMsg);
    _onError(errMsg);

}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:18,代码来源:BaseObserver.java

示例4: sendLogRequest

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
/**
 * 开始解析发送参数
 */
private void sendLogRequest(Request request) throws IOException {
    if (request != null) {
        String body = "";
        if (request.body() != null) {
            Buffer buffer = new Buffer();
            request.body().writeTo(buffer);
            //编码设为UTF-8
            Charset charset = Charset.forName("UTF-8");
            MediaType contentType = request.body().contentType();
            if (contentType != null) {
                charset = contentType.charset(Charset.forName("UTF-8"));
            }
            body = buffer.readString(charset);
            //如果你出现中文参数乱码情况,请进行URL解码处理!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
            body = URLEncoder.encode(body, "UTF-8");
        }
        LogUtils.i("发送----" + "method:" + request.method() + "  url:" + request.url() + "  body:" + body);
    }
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:23,代码来源:BaseInterceptor.java

示例5: sendLogResponse

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
/**
 * 开始解析服务器返回参数
 */
private void sendLogResponse(Response response) throws IOException {
    String rBody = "";
    if (response != null && response.body() != null) {
        BufferedSource source = response.body().source();
        source.request(Long.MAX_VALUE); // Buffer the entire body.
        Buffer buffer = source.buffer();

        Charset charset = Charset.forName("UTF-8");
        MediaType contentType = response.body().contentType();
        if (contentType != null) {
            try {
                charset = contentType.charset(Charset.forName("UTF-8"));
            } catch (UnsupportedCharsetException e) {
                e.printStackTrace();
            }
        }
        rBody = buffer.clone().readString(charset);
    }
    LogUtils.i("接收:" + rBody.toString());
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:24,代码来源:BaseInterceptor.java

示例6: onClick

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
public void onClick(View v) {
    new AlertDialog.Builder(fragment.getActivity()).setItems(itemsName, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (which == 0) {
                TopicsDiscount.Item item = items.get(getLayoutPosition());
                Uri uri = Parse.parsePSNStoreUrl(item.getStoreURL(), item.getRegion());
                LogUtils.d(uri);
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                ActivityUtils.startActivity(intent);
            } else if (which == 1) {
                Bundle bundle = new Bundle();
                bundle.putString("url", items.get(getLayoutPosition()).getActivityURL());
                ActivityUtils.startActivity(bundle, TopicActivity.class);
            }
        }
    }).show();
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:20,代码来源:TopicsDiscountListAdapter.java

示例7: getData

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
public void getData() {
    swipeRefreshLayout.setRefreshing(true);
    if (url.contains("gif") && !url.contains("large")) {
        url = Parse.parseImageUrl(url, 0);
    }
    list.clear();
    list.add(getString(R.string.save));
    if (!url.contains("large")) {
        list.add(getString(R.string.view_original_image));
    }
    alertDialog = new AlertDialog.Builder(this)
            .setTitle(R.string.option)
            .setItems(list.toArray(new String[list.size()]), this).create();
    LogUtils.d("Load image: " + url);
    if (url.contains("gif")) {
        Glide.with(this).asGif().load(url).into(new ImageViewTarget<GifDrawable>());
    } else {
        Glide.with(this).load(url).into(new ImageViewTarget<>());
    }
}
 
开发者ID:RanKKI,项目名称:PSNine,代码行数:22,代码来源:ImageViewActivity.java

示例8: apply

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
public ObservableSource<T> apply(@NonNull Observable<BaseHttpResult<T>> upstream) {
    return upstream.map(new Function<BaseHttpResult<T>, T>() {
        @Override
        public T apply(@NonNull BaseHttpResult<T> tBaseHttpResult) throws Exception {
            if (tBaseHttpResult == null) {
                throw new ServerException(ErrorType.EMPTY_BEAN, "解析对象为空");
            }
            LogUtils.e(TAG, tBaseHttpResult.toString());
            if (tBaseHttpResult.getStatus() != ErrorType.SUCCESS) {
                throw new ServerException(tBaseHttpResult.getStatus(),
                        tBaseHttpResult.getMessage());
            }
            return tBaseHttpResult.getData();
        }
    }).onErrorResumeNext(new Function<Throwable, ObservableSource<? extends T>>() {
        @Override
        public ObservableSource<? extends T> apply(@NonNull Throwable throwable)
                throws Exception {
            // ExceptionEngine 为处理异常的驱动器 throwable
            throwable.printStackTrace();
            return Observable.error(ExceptionEngine.handleException(throwable));
        }
    });

}
 
开发者ID:wang2016215,项目名称:Bing,代码行数:27,代码来源:ErrorTransformer.java

示例9: onPostExecute

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
protected void onPostExecute (Throwable param) {
    getRootActivity().showProgress(false, null);
    if (param != null) {
        LogUtils.e(TAG, param);
        if (BuildConfig.DEBUG) param.printStackTrace();
        getRootActivity().setTextColor(Color.RED);
        getRootActivity().setText(getString(R.string.workspace_init_error));
        return;
    }
    if (screen == null || !hasXml) {
        getRootActivity().setTextColor(Color.BLACK);
        getRootActivity().setText(getString(R.string.empty));
    } else {
        setPreferenceScreen(screen);
    }
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:18,代码来源:XmlListFragment.java

示例10: initLog

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
public void initLog() {
    LogUtils.Config config = LogUtils.getConfig()
            .setLogSwitch(BuildConfig.DEBUG)// 设置 log 总开关,包括输出到控制台和文件,默认开
            .setConsoleSwitch(BuildConfig.DEBUG)// 设置是否输出到控制台开关,默认开
            .setGlobalTag(null)// 设置 log 全局标签,默认为空
            // 当全局标签不为空时,我们输出的 log 全部为该 tag,
            // 为空时,如果传入的 tag 为空那就显示类名,否则显示 tag
            .setLogHeadSwitch(true)// 设置 log 头信息开关,默认为开
            .setLog2FileSwitch(false)// 打印 log 时是否存到文件的开关,默认关
            .setDir("")// 当自定义路径为空时,写入应用的/cache/log/目录中
            .setFilePrefix("")// 当文件前缀为空时,默认为"util",即写入文件为"util-MM-dd.txt"
            .setBorderSwitch(true)// 输出日志是否带边框开关,默认开
            .setConsoleFilter(LogUtils.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
            .setFileFilter(LogUtils.V)// log 文件过滤器,和 logcat 过滤器同理,默认 Verbose
            .setStackDeep(1);// log 栈深度,默认为 1
    LogUtils.d(config.toString());
}
 
开发者ID:Blankj,项目名称:AndroidUtilCode,代码行数:18,代码来源:UtilsApp.java

示例11: onStart

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
protected void onStart() {
    super.onStart();
    // 注册普通广播
    mReceiver1 = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String str = intent.getStringExtra("name");
            LogUtils.i("onReceive(普通广播,动态注册): " + str);
        }
    };
    IntentFilter filter1 = new IntentFilter();
    filter1.addAction("com.sdwfqin.broadcastdemo");
    registerReceiver(mReceiver1, filter1);

    // ===================================================
    // 注册本地广播
    mReceiver2 = new LocalBroadcastReceiver();
    IntentFilter filter2 = new IntentFilter();
    filter2.addAction("com.sdwfqin.broadcastdemo3");
    LocalBroadcastManager.getInstance(BroadcastActivity.this).registerReceiver(mReceiver2, filter2);
}
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:23,代码来源:BroadcastActivity.java

示例12: draw

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
private void draw() {
    try {
        // 获取Canvas对象
        mCanvas = mHolder.lockCanvas();
        // SurfaceView背景
        mCanvas.drawColor(Color.WHITE);
        mCanvas.drawPath(mPath, mPaint);
    } catch (Exception e) {
        LogUtils.e("draw: ", e);
    } finally {
        if (mCanvas != null) {
            // 提交画布内容
            mHolder.unlockCanvasAndPost(mCanvas);
        }
    }
}
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:17,代码来源:MySurfaceView.java

示例13: run

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
public void run() {
    long start = System.currentTimeMillis();
    while (mIsDrawing) {
        draw();
    }
    long end = System.currentTimeMillis();
    // 50-100
    if (end - start < 100) {
        try {
            Thread.sleep(100 - (end - start));
        } catch (InterruptedException e) {
            LogUtils.i("run: ", e);
        }
    }
}
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:17,代码来源:DbSurfaceView.java

示例14: draw

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
private void draw() {
    try {
        // 获取Canvas对象
        mCanvas = mHolder.lockCanvas();
        // SurfaceView背景
        mCanvas.drawColor(Color.WHITE);
        mCanvas.drawPath(mPath, mPaint);
    } catch (Exception e) {
        LogUtils.i("draw: ", e);
    } finally {
        if (mCanvas != null) {
            // 提交画布内容
            mHolder.unlockCanvasAndPost(mCanvas);
        }
    }
}
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:17,代码来源:DbSurfaceView.java

示例15: onDraw

import com.blankj.utilcode.util.LogUtils; //导入依赖的package包/类
@Override
    protected void onDraw(Canvas canvas) {
        LogUtils.i("onDraw: ");
        //不删除的画会默认绘制输入的文字
//        super.onDraw(canvas);

        switch (psdType) {
            case psdType_weChat:
                drawWeChatBorder(canvas);
                break;
            case psdType_bottomLine:
                drawBottomBorder(canvas);
                break;
            default:
                break;
        }

        drawPsdCircle(canvas);
    }
 
开发者ID:sdwfqin,项目名称:AndroidSamples,代码行数:20,代码来源:PayPwdInputView.java


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