android 浏览器插件开发 - Log

来源:互联网 发布:淘宝店铺东西没人买 编辑:程序博客网 时间:2024/06/08 19:04

转载请注明出处:http://blog.csdn.net/awebkit


    android中的插件开发中的示例代码已经给我们说明了如何打log,参看示例代码main.cpp

    for (int i = 0; i < argc; i++) {        if (!strcmp(argn[i], "DrawingModel")) {            if (!strcmp(argv[i], "Bitmap")) {                model = kBitmap_ANPDrawingModel;            }               else if (!strcmp(argv[i], "Surface")) {               model = kSurface_ANPDrawingModel;            }               gLogI.log(kDebug_ANPLogType, "------ %p DrawingModel is %d", instance, model);            break;        }       }   
    我们可以使用gLogI.log打印调试信息。

    gLogI的定义如下

ANPLogInterfaceV0           gLogI;

     ANPLogInterfaceV0的定义如下(Android_npapi.h)

struct ANPLogInterfaceV0 : ANPInterface {    /** dumps printf messages to the log file        e.g. interface->log(instance, kWarning_ANPLogType, "value is %d", value);     */    void (*log)(ANPLogType, const char format[], ...);};
       该结构的赋值如下(ANPLogInterface.cpp)
static void anp_log(ANPLogType logType, const char format[], ...) {    va_list args;    va_start(args, format);    android_LogPriority priority;    switch (logType) {        case kError_ANPLogType:            priority = ANDROID_LOG_ERROR;            break;        case kWarning_ANPLogType:            priority = ANDROID_LOG_WARN;            break;        case kDebug_ANPLogType:            priority = ANDROID_LOG_DEBUG;            break;        default:            priority = ANDROID_LOG_UNKNOWN;            break;    }    LOG_PRI_VA(priority, "plugin", format, args);    va_end(args);}void ANPLogInterfaceV0_Init(ANPInterface* value) {    ANPLogInterfaceV0* i = reinterpret_cast<ANPLogInterfaceV0*>(value);    i->log = anp_log;}
    而LOG_PRI_VA的调用关系如下 

LOG_PRI_VA@Log.handroid_vprintLog@Log.h __android_log_vprint@Log.h__android_log_write@logd_write.cwrite_to_log@logd_write.c__write_to_log_init@logd_write.c__write_to_log_kernel@logd_write.cwritev@uio.c


    注:

    1. 插件的打印信息的channel为plugin

    2. android系统据我所知,只有如下log会受到是否打开DEBUG的影响

         LOGV*  LOG_FATAL*

原创粉丝点击