Recently, the company's testing always put forward such a bug, of course, also blame their code is bad, so the test will always crash the app, and their side of the crash when there is no log printing, their return to reproduce some time is really bad reproduce it, so the trouble came. In order to easily see the cause of the test phone bug, at home at the weekend to write a small tool, as long as the log class in the project to add the Logphoneutil class printing, you can easily in the app's mobile phone to save the log. A brief introduction to the idea, source code on GitHub, you can also view it yourself. Https://github.com/MuBob/PhoneLogUtil;
The log file management class Fileutil is first written to detect the presence of SDcard to create log files under different directories.
The Ioutil class is then created to read and write to the log file, which is used to manipulate the file stream for file write operations.
Finally, the Logutil class is created, and the corresponding filter words are called at the place of printing.
Simple three-step, the key is in the Logutil class to read and write to the file, in order not to operate in the main thread to cause the interface lag phenomenon, the need to turn on the child thread, and open the sub-thread, the need to lock the log file, so that you can easily use this tool class.
Save app Run log on Android phone using Logphoneutil tool class