浅谈Android系统开发中LOG的使用
来源:互联网 发布:mac虚拟机连不上网 编辑:程序博客网 时间:2024/06/06 14:04
Android系统中的Java日志接口。Android系统在Frameworks层中定义了Log接口(frameworks/base/core/java/android/util/Log.java):
- ................................................
- public final class Log {
- ................................................
- /**
- * Priority constant for the println method; use Log.v.
- */
- public static final int VERBOSE = 2;
- /**
- * Priority constant for the println method; use Log.d.
- */
- public static final int DEBUG = 3;
- /**
- * Priority constant for the println method; use Log.i.
- */
- public static final int INFO = 4;
- /**
- * Priority constant for the println method; use Log.w.
- */
- public static final int WARN = 5;
- /**
- * Priority constant for the println method; use Log.e.
- */
- public static final int ERROR = 6;
- /**
- * Priority constant for the println method.
- */
- public static final int ASSERT = 7;
- .....................................................
- public static int v(String tag, String msg) {
- return println_native(LOG_ID_MAIN, VERBOSE, tag, msg);
- }
- public static int v(String tag, String msg, Throwable tr) {
- return println_native(LOG_ID_MAIN, VERBOSE, tag, msg + '\n' + getStackTraceString(tr));
- }
- public static int d(String tag, String msg) {
- return println_native(LOG_ID_MAIN, DEBUG, tag, msg);
- }
- public static int d(String tag, String msg, Throwable tr) {
- return println_native(LOG_ID_MAIN, DEBUG, tag, msg + '\n' + getStackTraceString(tr));
- }
- public static int i(String tag, String msg) {
- return println_native(LOG_ID_MAIN, INFO, tag, msg);
- }
- public static int i(String tag, String msg, Throwable tr) {
- return println_native(LOG_ID_MAIN, INFO, tag, msg + '\n' + getStackTraceString(tr));
- }
- public static int w(String tag, String msg) {
- return println_native(LOG_ID_MAIN, WARN, tag, msg);
- }
- public static int w(String tag, String msg, Throwable tr) {
- return println_native(LOG_ID_MAIN, WARN, tag, msg + '\n' + getStackTraceString(tr));
- }
- public static int w(String tag, Throwable tr) {
- return println_native(LOG_ID_MAIN, WARN, tag, getStackTraceString(tr));
- }
- public static int e(String tag, String msg) {
- return println_native(LOG_ID_MAIN, ERROR, tag, msg);
- }
- public static int e(String tag, String msg, Throwable tr) {
- return println_native(LOG_ID_MAIN, ERROR, tag, msg + '\n' + getStackTraceString(tr));
- }
- ..................................................................
- /**@hide */ public static native int println_native(int bufID,
- int priority, String tag, String msg);
- }
因此,如果要使用Java日志接口,只要在类中定义的LOG_TAG常量和引用android.util.Log就可以了:
private static final String LOG_TAG = "MY_LOG_TAG";
Log.i(LOG_TAG, "This is the log printed by Log.i in android user space.");
要查看这些LOG的输出,可以配合logcat工具。如果是在Eclipse环境下运行模拟器,并且安装了Android插件,那么,很简单,直接在Eclipse就可以查看了:
0 0
- 浅谈Android系统开发中LOG的使用--LOG(3)
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用
- 浅谈Android系统开发中LOG的使用zz
- 为什么寄存器比内存快?
- android之service(一)
- What Every App Developer Should Know About Android
- linux脚本编程---linux添加新用户解决恢复系统设置
- mysql下的加密函数
- 浅谈Android系统开发中LOG的使用
- U-Boot启动第二阶段代码分析
- 十. 加班等于团队建设?
- 十一. 没有这4项素质,别想在创业公司
- TortoiseGit配合msysGit在Git@OSC代码托管的傻瓜教程
- 【ccs13】Accepted papper list & part of download
- poj 1286 Necklace of Beads polya计数
- 十二.200多万元得到的创业教训--app名字是关键
- 一些曾经的奉为经典的做法都被颠覆了