避免直接依赖 android log 库

来源:互联网 发布:淘宝科技有限公司 编辑:程序博客网 时间:2024/06/08 05:21

此文版权属于作者所有,任何人、媒体或者网站转载、借用都必须征得作者本人同意!

#include <android/log.h>#include <dlfcn.h> /* dlsym */typedef int (*log_print_fun)(int, const char*,  const char*, ...);static log_print_fun log_print =        (log_print_fun) dlsym(RTLD_DEFAULT, "__android_log_print");  static const char LOG_TAG[] = "helloworld";#define LOGT(...) log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)#define LOGW(...) log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)


0 0
原创粉丝点击