This tool class was created for two reasons

1. I like log information very much, but the log information can only be seen on the console connected to the computer

2. One day the test asked me, “Where do you keep these logs on your phone? How can I get them out and have a look?”

So I tried to write a visual, autosave Log utility class

Making portal

Making portal

Let’s take a look at the effect

1. First effect in console

2. Effects on mobile phones

3. The file is saved locally

4. The amount of code is also very small

Log tool class implementation

Before realizing any one thing, we should first conceive the framework, want to understand the relationship between classes and classes, convenient for us to better understand, maintain and expand, so in this first look at the wrong I draw! UML class diagrams

The key code

1. There are three red boxes for thread, stack, and details

2. If the stack depth returns 0, no stack information is output. StackTraceUtil filters out unnecessary stack information

3. Finally, all printers that you have added will be iterated through to print your log

So it’s very simple stuff. Let me know if you see any problems or better ideas!