In the standard Android Java program, the logcat mechanism is perfect and easy to understand. Here we mainly talk about the log output method in the C/C ++ program.
1. First, include <cutils/log. h> In the. C or. cpp file where you want to print logs.
Almost all macros of the print function are recorded in this header file.
2. Use the print function android_printlog () where you want to output the log. The function is written as follows:
Android_printlog (PRIO, Tag, FMT );
The PRIO parameter indicates the log level you print, for example, android_log_debug;
The parameter tag indicates the log you print, which is useful when filtering log information;
The FMT parameter indicates the printing format of a variable.
Example: android_printlog (android_log_debug, "WebKit", "The mimetype is % d", mimetype); // assume that mimetype is an integer variable.
------- End --------