Chinaunix首页 | 论坛 | 博客
  • 博客访问: 190332
  • 博文数量: 47
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 470
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-18 12:09
个人简介

be a happy lazy and fat cat

文章分类
文章存档

2017年(1)

2016年(5)

2015年(22)

2014年(19)

我的朋友

分类: Android平台

2014-11-17 16:27:41


内核开发的log
printk提供了8种日志级别():

[cpp] view plaincopy在CODE上查看代码片派生到我的代码片

    #define KERN_EMERG  "<0>"     /* system is unusable           */  
    #define KERN_ALERT  "<1>"     /* action must be taken immediately */  
    #define KERN_CRIT   "<2>"     /* critical conditions          */  
    #deinfe KERN_ERR    "<3>"     /* error conditions         */  
    #deinfe KERN_WARNING    "<4>"     /* warning conditions           */  
    #deinfe KERN_NOTICE "<5>"     /* normal but significant condition */  
    #deinfe KERN_INFO   "<6>"     /* informational            */  
    #deinfe KERN_DEBUG  "<7>"     /* debug-level messages         */  

       printk的使用方法:

       printk(KERN_ALERT"This is the log printed by printk in linux kernel space.");
    cat  /proc/kmsg



要在c/c++中使用Log,很简单。通常的做法是:
定义自己的TAG_LOG宏;包含头文件log.h;然后在需要记录Log的地方直接用LOGV/LOGD/LOGI/LOGW/LOGE等即可。
比如,文件lights.c中就在开头这样写,
#define LOG_TAG "lights"
#include
需要在.mk文件新增如下
common_shared_libraries :=libutils liblog
LOCAL_SHARED_LIBRARIES := $(common_shared_libraries)

然后在该文件的后续部分,直接用ALOGV/ALOGE等来输出日志就可以。

java code log
import 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.");
阅读(1656) | 评论(0) | 转发(0) |
0

上一篇:curl question

下一篇:c++重载 覆盖区别

给主人留下些什么吧!~~