在关机充电界面,想在cpp程序中输出printf的内容,但是发现在串口终端中无法显示这类log,所以得想其他办法来让其可在串口终端上显示出来,调试程序会方便很多。
方法如下:
1、打开\system\core\include\cutils\klog.h
添加一行自定义的打印tag
#define KLOG_BOOTINFO(tag,x...) klog_write(KLOG_PERFORMANCE_LEVEL, "<0>" tag ": " x)
2、在需要打印log的地方添加引用,这样打印的内容在串口终端中就可以正常显示了。
#include <cutils/klog.h>
#define BOOTINFO(x...) KLOG_BOOTINFO("graphic", x)
#define BOOTINFO(x...) KLOG_BOOTINFO("graphic", x)
BOOTINFO("pis gr_init_font entry.\n");