Save app Run log on Android phone using Logphoneutil tool class

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.