zoukankan      html  css  js  c++  java
  • java的logcat的简单使用

    android.util.Log常用的方法有以下5个:Log.v() Log.d() Log.i() Log.w() 以及 Log.e() 。根据首字母对应VERBOSEDEBUG,INFO, WARN,ERROR。

    1、Log.v 的调试颜色为黑色的,任何消息都会输出,这里的v代表verbose啰嗦的意思,平时使用就是Log.v("","");

    2、Log.d的输出颜色是蓝色的,仅输出debug调试的意思,但他会输出上层的信息,过滤起来可以通过DDMS的Logcat标签来选择.

    3、Log.i的输出为绿色,一般提示性的消息information,它不会输出Log.v和Log.d的信息,但会显示i、w和e的信息

    4、Log.w的意思为橙色,可以看作为warning警告,一般需要我们注意优化Android代码,同时选择它后还会输出Log.e的信息。

    5、Log.e为红色,可以想到error错误,这里仅显示红色的错误信息,这些错误就需要我们认真的分析,查看栈的信息了。

    注意:不同的打印方法在使用时都是某个方法带上(String tag, String msg)参数,tag表示的是打印信息的标签,msg表示的是需要打印的信息。

    package com.example.demo;  
    import android.os.Bundle;  
    import android.app.Activity;  
    import android.view.Menu;  
    import android.util.Log;  
    public class MainActivity extends Activity {  
    final static String TAG="LOGCAT";  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
    super.onCreate(savedInstanceState);  
    setContentView(R.layout.activity_main);  
    Log.v(TAG,"verbose");  
    Log.d(TAG,"Debug");  
    Log.i(TAG,"Info");  
    Log.w(TAG,"Warn");  
    Log.e(TAG,"Error");  
    }  
    @Override  
    public boolean onCreateOptionsMenu(Menu menu) {  
    // Inflate the menu; this adds items to the action bar if it is present.  
    getMenuInflater().inflate(R.menu.main, menu);  
    return true;  
    }  
    }  
    

      

  • 相关阅读:
    图像修补
    图像的矩
    使用多边形将轮廓包围
    寻找物体的凸包
    查找并绘制轮廓
    重映射
    霍夫变换
    边缘检测
    第二周神经网络基础
    第一周:深度学习引言(Introduction to Deep Learning)
  • 原文地址:https://www.cnblogs.com/caimuqing/p/5842368.html
Copyright © 2011-2022 走看看