Android provides a user-level lightweight LOG Mechanism. Its implementation runs through Java, JNI, local c/c ++ implementation, Linux kernel driver, and Other Android layers. It is simple and clear enough, it is a pretty good case. This series of articles explains the internal implementation mechanism of the LOG mechanism. This is the first article in the series to explain the implementation architecture of the LOG mechanism.
LOG running environment
It is the Android Debug environment provided on the official website of Android.
The LOG Mechanism of Android is also running in this environment. We focus on the running part of Emulator and Device. App VMs generates LOG information and interacts with ADB Device Daemon to output this information, the ADB Device Daemon interacts with the ADB Host Daemon running on the PC through a USB (Device) or a local connection (Emulator) through the corresponding protocol, it is presented to users through debugging tools on the PC. The interaction between JDWP Debugger, DDMS, ADB Host Daemon, and ADB Device Daemon is not covered in this article. The content discussed in this article runs on Emulator/Device to generate LOG information and output it through the program LogCat.
Implementation architecture of LOG
Shows the implementation architecture of LOG in Android. This is basically the classic architecture of a module in Android that implements various layers.
Android applications operate through the mechanism provided by the Framework; Java requires local c/c ++ to provide services, implemented through JNI; JNI calls the underlying library; the library function operates the device by operating the mapped device file, and the Driver in LINUX kernel performs the corresponding operations. Besides Java and JNI, the c/c ++ program of the user domain on LINUX can also be completed by operating the device file.
Android LOG is also implemented in this way and will be described separately in this series of articles. The application uses android. util. various static methods in Log, output LOG information [detailed description in Series 2]; Log calls the implementation of c/c ++ through the JNI interface, while locally implemented write LOG, that is, write information to the device file [Detailed description of the three articles in series]; the device file is a lightweight driver logger of LINUX written by Android for the LOG mechanism [details in series 4]; the LOG information can be displayed by the LogCat program running on the Emulator/Device [details of the fifth series]. In addition, the local implementation library of Android can also use the existing mechanism, directly output LOG in the c/c ++ space [details in Series 6].