|
需求:第三方提供的so库有太多log,影响开发测试,需要关闭 分析:任何程序(包括so)都是调用系统的log,所以在系统的log函数中肯定可以过滤 过程:根据tag过滤 system/core/liblog/logger_write.c
LIBLOG_ABI_PUBLIC int __android_log_buf_write(int bufID, int prio, const char* tag, const char* msg) { struct iovec vec[3]; char tmp_tag[32]; if (!tag) tag = ""; if(!strncmp(tag + 1, "xxxx" + 1, strlen("xxxx") - 1)) return -EINVAL; if(!strncmp(tag + 1, "yyyy" + 1, strlen("yyyy") - 1)) return -EINVAL;
总结:系统默认会根据tag,把一些log归类到radio部分,可以在这个地方添加过滤的逻辑 此外还可以根据log_level过滤掉系统的一些低级别的log 这个库尽量不要经常修改,因为好多module依赖这个,所以导致整个make会编译很多模块
|